Skip to content
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

Add rocksdb sources to the go package #90

Closed
anatol opened this issue Sep 17, 2022 · 4 comments
Closed

Add rocksdb sources to the go package #90

anatol opened this issue Sep 17, 2022 · 4 comments

Comments

@anatol
Copy link

anatol commented Sep 17, 2022

Hi y'all,

I am trying to use this package for my go project and I found its installation/setup procedure quite complicated. By default the package gives following compilation error:

➜  rocksdb go build
# github.com/linxGnu/grocksdb
../../go/pkg/mod/github.com/linx!gnu/[email protected]/array.go:4:11: fatal error: rocksdb/c.h: No such file or directory
    4 | // #include "rocksdb/c.h"
      |           ^~~~~~~~~~~~~
compilation terminated.

To use grocksdb bindings additional steps are required to compile rocksdb and its dependencies.

A better solution would be to let cgo compile the rocksdb sources. Similar to how sqlite3 go bindings do. cgo just picks *.c files stored together with go sources then compiles and automatically links it.

This requires an amalgamation file (i.e. a single file that contains all project sources) to be provided by rocksdb project (like sqlite does). It turns out rocksdb has a tool for that https://github.com/facebook/rocksdb/blob/main/build_tools/amalgamate.py that aim to achieve what we need.

@linxGnu
Copy link
Owner

linxGnu commented Sep 26, 2022

@anatol Adding rocksdb and its dependency code base makes the repository heavy and makes compile time much higher than before.

Not only that, RocksDB is not C but C++. Making go <> c++ interoperability is very high cost.

@anatol
Copy link
Author

anatol commented Sep 26, 2022

@anatol Adding rocksdb and its dependency code base makes the repository heavy and makes compile time much higher than before.

True, rocksdb is a heavy dependency and requires a lot of time to compile unfortunately.

Not only that, RocksDB is not C but C++. Making go <> c++ interoperability is very high cost.

You already use this C++-C bridge with your CGO method. Using amalgamated sources does not change anything here. In fact, joining sources into one compilation unit allows compiler to use more optimizations.

@yihuang
Copy link
Contributor

yihuang commented Dec 24, 2022

it's pretty easy to manage c dependencies with nix, but need this small change though: #100

@linxGnu
Copy link
Owner

linxGnu commented Jan 28, 2023

I will close this ticket. Thank you all for the suggestion.

@linxGnu linxGnu closed this as completed Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants