-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
current package layout hurts compile time and binary sizes #113
Comments
We're currently using build tags for this, at least for a couple of the backends (see e.g. BoltDB and RocksDB). Would this work for BadgerDB as well? |
Hm, I guess it works, but then every project depending on one of these databases must specify the build tag every single time they build their project. In comparison, the "import as needed" approach doesn't require specifying build tags every time. |
Sure, but that's sort of by design - in e.g. Tendermint the database backend is configurable at runtime, and so build tags are a mechanism for controlling which backends should be available in the Tendermint binary. |
You could still implement that if you wanted, though - it would probably be fifty or so lines on top of the "import as needed" mechanism. My point of view is someone who uses tendermint libraries, so I want to be able to use |
That's true, we could have the backends as independent subpackages and use build-tags in the root package to control which ones to include in a "full" build - although it might get a bit confusing. What do you think @melekes? |
You'll probably need a separate package from the root, though, because if the interface is also at the root package you would have import cycles. You could have a new package at |
Makes sense, |
Sure, I can send a PR after my badger one. |
BadgerDB is pretty heavy, let's not include it by default. Related to #113.
Since all the DB libraries are imported from a single package, using a single one of them requires building all of them. And since each is registered globally, they must be bundled in the final binary too.
This will get worse as more DB implementations are added (#38). I made a write-up about this, and potential solutions, on ChainSafe/chaindb#2 since that module has a similar issue.
Similarly, I think a database implementation called
foo
should live atjackfan.us.kg/tendermint/tm-db/foo
. Then, to use it, one would need to call a constructor likefoo.New(...)
instead ofdb.NewDB("foo", ...)
. This way, because the user only imports the database implementations they need, Go only builds and links the libraries as needed, not all of them at once.The text was updated successfully, but these errors were encountered: