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

BenchmarkMedium panicking on memdb #908

Closed
ajnavarro opened this issue Jun 16, 2023 · 0 comments · Fixed by #1602
Closed

BenchmarkMedium panicking on memdb #908

ajnavarro opened this issue Jun 16, 2023 · 0 comments · Fixed by #1602
Labels
🐞 bug Something isn't working 📦 🌐 tendermint v2 Issues or PRs tm2 related

Comments

@ajnavarro
Copy link
Contributor

BenchmarkMedium panicking on memdb

Description

When executing benchmark BenchmarkMedium it panics with a nil pointer exception.

Steps to reproduce

  • Execute the benchmark BenchmarkMedium

Logs

goos: linux
goarch: amd64
pkg: github.com/gnolang/gno/tm2/pkg/iavl/benchmarks
cpu: AMD Ryzen 5 5600X 6-Core Processor
BenchmarkMedium
BenchmarkMedium/memdb-100000-100-16-40
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x7b4ee7]

goroutine 24 [running]:
github.com/gnolang/gno/tm2/pkg/iavl.newNodeDB({0x0, 0x0}, 0x186a0)
	/home/ajnavarro/workspace/active/gno/tm2/pkg/iavl/nodedb.go:49 +0x27
github.com/gnolang/gno/tm2/pkg/iavl.NewMutableTree({0x0?, 0x0?}, 0x0?)
	/home/ajnavarro/workspace/active/gno/tm2/pkg/iavl/mutable_tree.go:24 +0x27
github.com/gnolang/gno/tm2/pkg/iavl/benchmarks.prepareTree(0xc0001a8280, {0x0, 0x0}, 0x186a0, 0x0?, 0x46c3ce?)
	/home/ajnavarro/workspace/active/gno/tm2/pkg/iavl/benchmarks/bench_test.go:29 +0x66
github.com/gnolang/gno/tm2/pkg/iavl/benchmarks.runSuite(0xc0001a8280, {0x0, 0x0}, 0x4907b7?, 0x64, 0x10, 0x28)
	/home/ajnavarro/workspace/active/gno/tm2/pkg/iavl/benchmarks/bench_test.go:289 +0xa7
github.com/gnolang/gno/tm2/pkg/iavl/benchmarks.runBenchmarks.func2(0xc0001a8280?)
	/home/ajnavarro/workspace/active/gno/tm2/pkg/iavl/benchmarks/bench_test.go:268 +0x35
testing.(*B).runN(0xc0001a8280, 0x1)
	/usr/local/go/src/testing/benchmark.go:193 +0x102
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:233 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:226 +0x9c
exit status 2
FAIL	github.com/gnolang/gno/tm2/pkg/iavl/benchmarks	0.007s
@ajnavarro ajnavarro added 🐞 bug Something isn't working 📦 🌐 tendermint v2 Issues or PRs tm2 related labels Jun 16, 2023
@moul moul moved this to 🏆 Needed for Launch in 🚀 The Launch [DEPRECATED] Sep 5, 2023
@moul moul modified the milestone: 🚀 main.gno.land Sep 6, 2023
thehowl added a commit that referenced this issue Mar 1, 2024
Changes mostly involve shuffling code around.

The `db` package now has its basic types and helper functions in
`pkg/db`, and then sub-packages for each DB which is actually used. This
allows a package using it to only import the database code it needs.

The end goal I wanted was to remove the transitive dependency of
`cmd/gno` on `goleveldb`. Turns out this is more complicated than I
thought. In any case, I already did it in another branch; will make a
second PR shortly after this one.

Notes for reviewing:

- `pkg/db` has also the helper packages `_all` and `_tags`.
- `_all` imports all the databases while respecting the `cgo` build
tag.[^1] (This is automatically set by the go compiler depending on
whether cgo is enabled).
- The `_tags` package, instead, imports the databases specified by the
build tags. I meant this for end-user binaries, like gno.land eventually
(currently it only supports GoLevelDB), so a user can compile with the
given build tags.
- I removed `badger` and `gorocksdb`. They were so important that they
didn't compile and nobody noticed.
- `badger` probably makes sense to be re-added and tried out eventually,
but it's outside of the scope of this PR.
- `gorocksdb` is unmaintained and will not compile with the latest
version of RocksDB. In fact, we already had a DB implementation for
[grocksdb](https://github.com/linxGnu/grocksdb), the maintained fork. I
fixed some code there too to actually make it compile.
- Removing the two dependencies made our `go.mods` a bunch lighter.
:tada:
- Some changes also involve the CI. 
- I removed splitting the build for each database being tested, as the
tests on the package run quickly anyway so there is no real need to
split them.
- I also severely downgraded `grocksdb` so that its version is
compatible with the version of RocksDB present on ubuntu 22.04's
repositories. There could be a variety of different changes to the CI to
allow building on a more recent version of the database; but after
having seen that the compilation of RocksDB on a beefy machine with
`make -j4` is already beyond 5 mintues, I decided we don't need a slow
CI for a feature literally no-one uses, so here we are.
- This PR also fixes the benchmarks in `tm2/pkg/iavl/benchmarks` (fixes
#908). [The fix itself is
stupid.](87ea39d#diff-112673453ecf482fb6bfd8004ebc11eff7536b812cc48bd6dff3328767550908R227-R229)

[^1]: A while ago I was upset that my go compilation was taking long and
then found out that it was using cgo for no apparent reason -- it's
actually because a few places in the standard library will by default
use cgo unless it's disabled. For this reason I actually set
`CGO_ENABLED=0` in my `.profile`.

---------

Co-authored-by: Antonio Navarro <antnavper@gmail.com>
leohhhn pushed a commit to leohhhn/gno that referenced this issue Mar 6, 2024
Changes mostly involve shuffling code around.

The `db` package now has its basic types and helper functions in
`pkg/db`, and then sub-packages for each DB which is actually used. This
allows a package using it to only import the database code it needs.

The end goal I wanted was to remove the transitive dependency of
`cmd/gno` on `goleveldb`. Turns out this is more complicated than I
thought. In any case, I already did it in another branch; will make a
second PR shortly after this one.

Notes for reviewing:

- `pkg/db` has also the helper packages `_all` and `_tags`.
- `_all` imports all the databases while respecting the `cgo` build
tag.[^1] (This is automatically set by the go compiler depending on
whether cgo is enabled).
- The `_tags` package, instead, imports the databases specified by the
build tags. I meant this for end-user binaries, like gno.land eventually
(currently it only supports GoLevelDB), so a user can compile with the
given build tags.
- I removed `badger` and `gorocksdb`. They were so important that they
didn't compile and nobody noticed.
- `badger` probably makes sense to be re-added and tried out eventually,
but it's outside of the scope of this PR.
- `gorocksdb` is unmaintained and will not compile with the latest
version of RocksDB. In fact, we already had a DB implementation for
[grocksdb](https://github.com/linxGnu/grocksdb), the maintained fork. I
fixed some code there too to actually make it compile.
- Removing the two dependencies made our `go.mods` a bunch lighter.
:tada:
- Some changes also involve the CI. 
- I removed splitting the build for each database being tested, as the
tests on the package run quickly anyway so there is no real need to
split them.
- I also severely downgraded `grocksdb` so that its version is
compatible with the version of RocksDB present on ubuntu 22.04's
repositories. There could be a variety of different changes to the CI to
allow building on a more recent version of the database; but after
having seen that the compilation of RocksDB on a beefy machine with
`make -j4` is already beyond 5 mintues, I decided we don't need a slow
CI for a feature literally no-one uses, so here we are.
- This PR also fixes the benchmarks in `tm2/pkg/iavl/benchmarks` (fixes
gnolang#908). [The fix itself is
stupid.](gnolang@87ea39d#diff-112673453ecf482fb6bfd8004ebc11eff7536b812cc48bd6dff3328767550908R227-R229)

[^1]: A while ago I was upset that my go compilation was taking long and
then found out that it was using cgo for no apparent reason -- it's
actually because a few places in the standard library will by default
use cgo unless it's disabled. For this reason I actually set
`CGO_ENABLED=0` in my `.profile`.

---------

Co-authored-by: Antonio Navarro <antnavper@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🌐 tendermint v2 Issues or PRs tm2 related
Projects
Status: 🚀 Needed for Launch
Development

Successfully merging a pull request may close this issue.

2 participants