Mystery around embedded binary sizes on Mac

We build our binaries using go build -tags=embed -v. This allows gorocksdb to embed RocksDB into the binary. Then it can be run on any instance without the need to even install RocksDB.

The funny thing is that if I delete c-rocksdb, c-snappy and c-lz4 from my vendor and they aren’t even in my GOPATH, then also the above command succeeds and result in a much smaller binary size which is also built pretty fast.

After deleting rm -rf vendor/

➜  dgraph git:(master) ✗ go build -tags=embed -v .

The size of the binary that is built is 18M. Verified on a couple of Mac which didn’t have RocksDB that it worked. I suppose it uses the RocksDB installed on my machine somehow for embedding.

Without deleting the size of the binary is 55M and takes much longer to build. In this case the major time is spent on embedding c-rocksdb. Have to dig deeper into gorocksdb to understand whats happening here.


This is interesting, and also signifies that magical external packages are magical. And magic is bad in engineering :slight_smile:.

I knew that it uses the rocksdb installation on the compiling machine for the embedding, but this sort of inter-effect is really strange.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.