# Use pure Go zstd implementation

**URL:** <https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670>\
**Category:** Badger\
**Tags:** badger, kind:enhancement\
**Created:** [December 16, 2019, 11:42am UTC](https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670 "2019-12-16T11:42:51Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [June 20, 2020, 8:33am UTC](https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670/10 "2020-06-20T08:33:39Z")

</div>

[klauspost](https://github.com/klauspost) _commented_ :

> IIUC, I can decompress the data that was created by dataDog/zstd using klauspost/compres (which means they’re compatible), is this correct?

Yes they are compatible both ways. The only exception is 0 bytes of input which will give 0 bytes output with the Go zstd. But you already have the ` zstd.WithZeroFrames(true)` which will wrap 0 bytes in a header so it can be fed to DD zstd. This will of course only be relevant when downgrading.

I am fuzz testing the change above. It will have much less compression impact than completely disabling entropy coding, but will handle the random input blocks better. I would probably leave out the `WithNoEntropyCompression` and upgrade to the next version that will select this automatically when it makes sense.

> number of major page fails

The dd library allocates a lot. That could be why. Go zstd does not allocate for 4K blocks after a few runs.

> why wouldn’t you use CGO in your code?

Compiling is much slower. Cross compilation is a pain to set up/impossible for some. Deployment requires dependencies whereas plain Go is just the executable. cgo is inherently less secure since none of the c code has the security features the Go runtime provides.

---

_[View the full topic](https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670)._
