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

No pointer optimisation txn #142

Merged
merged 5 commits into from
Jun 13, 2024
Merged

Conversation

JkLondon
Copy link
Member

@JkLondon JkLondon commented Jun 12, 2024

Added optimization that changed txn.val to non-pointer that allows us to avoid cgoCheckUnknownPointer false-positive cgo behavior.
CI Check in Erigon: erigontech/erigon#10708

@JkLondon
Copy link
Member Author

BenchmarkCursor-20                      10000000               163.9 ns/op            16 B/op          1 allocs/op
BenchmarkCursor_Renew/1-20              10000000                57.63 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_Renew/2-20              10000000                55.57 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_Renew/3-20              10000000               162.2 ns/op            16 B/op          1 allocs/op
BenchmarkCursor_Renew/4-20              10000000                60.87 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_SetRange-20             10000000                97.85 ns/op            0 B/op          0 allocs/op
BenchmarkErrno_Error-20                 10000000               419.5 ns/op           224 B/op          4 allocs/op
BenchmarkTxn_abort-20                   10000000               220.2 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_ro-20                      10000000               529.2 ns/op           208 B/op          4 allocs/op
BenchmarkTxn_unmanaged_abort-20         10000000               193.4 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_unmanaged_commit-20        10000000               193.6 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_unmanaged_ro-20            10000000               367.2 ns/op            96 B/op          3 allocs/op
BenchmarkTxn_renew-20                   10000000               118.9 ns/op             0 B/op          0 allocs/op
BenchmarkTxn_Put_append-20              --- FAIL: BenchmarkTxn_Put_append-20
    txn_test.go:1198: put: mdbx_put: MDBX_MAP_FULL: Environment mapsize limit reached
BenchmarkTxn_Put_append_noflag-20       --- FAIL: BenchmarkTxn_Put_append_noflag-20
    txn_test.go:1235: put: mdbx_put: MDBX_MAP_FULL: Environment mapsize limit reached
BenchmarkTxn_Get-20                     10000000                81.72 ns/op            0 B/op          0 allocs/op

master

BenchmarkCursor-20                      10000000               159.9 ns/op            16 B/op          1 allocs/op
BenchmarkCursor_Renew/1-20              10000000                55.68 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_Renew/2-20              10000000                56.13 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_Renew/3-20              10000000               167.3 ns/op            16 B/op          1 allocs/op
BenchmarkCursor_Renew/4-20              10000000                61.07 ns/op            0 B/op          0 allocs/op
BenchmarkCursor_SetRange-20             10000000                88.18 ns/op            0 B/op          0 allocs/op
BenchmarkErrno_Error-20                 10000000               419.3 ns/op           224 B/op          4 allocs/op
BenchmarkTxn_abort-20                   10000000               217.9 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_ro-20                      10000000               546.7 ns/op           192 B/op          3 allocs/op
BenchmarkTxn_unmanaged_abort-20         10000000               198.7 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_unmanaged_commit-20        10000000               199.0 ns/op            64 B/op          1 allocs/op
BenchmarkTxn_unmanaged_ro-20            10000000               334.1 ns/op            80 B/op          2 allocs/op
BenchmarkTxn_renew-20                   10000000               114.4 ns/op             0 B/op          0 allocs/op
BenchmarkTxn_Put_append-20              --- FAIL: BenchmarkTxn_Put_append-20
    txn_test.go:1198: put: mdbx_put: MDBX_MAP_FULL: Environment mapsize limit reached
BenchmarkTxn_Put_append_noflag-20       --- FAIL: BenchmarkTxn_Put_append_noflag-20
    txn_test.go:1235: put: mdbx_put: MDBX_MAP_FULL: Environment mapsize limit reached
BenchmarkTxn_Get-20                     10000000                71.83 ns/op            0 B/op          0 allocs/op

txn.val replacement (branch no-pointer-optimisation-txn)

@JkLondon
Copy link
Member Author

goos: linux
goarch: amd64
pkg: github.com/erigontech/mdbx-go/mdbx
cpu: 12th Gen Intel(R) Core(TM) i7-12700H
                        │ txn_val_pointer.txt │       txn_val_non_pointer.txt       │
                        │       sec/op        │   sec/op     vs base                │
Cursor-20                         168.2n ± 2%   166.6n ± 1%        ~ (p=0.289 n=10)
Cursor_Renew/1-20                 55.84n ± 2%   55.73n ± 1%        ~ (p=0.197 n=10)
Cursor_Renew/2-20                 55.86n ± 3%   55.20n ± 0%   -1.18% (p=0.003 n=10)
Cursor_Renew/3-20                 167.0n ± 1%   165.6n ± 2%        ~ (p=0.342 n=10)
Cursor_Renew/4-20                 61.15n ± 3%   62.22n ± 3%        ~ (p=0.529 n=10)
Cursor_SetRange-20                96.72n ± 3%   90.24n ± 2%   -6.70% (p=0.000 n=10)
Errno_Error-20                    383.7n ± 8%   377.3n ± 7%        ~ (p=0.436 n=10)
Txn_abort-20                      207.8n ± 1%   210.8n ± 2%        ~ (p=0.060 n=10)
Txn_ro-20                         465.2n ± 5%   463.2n ± 6%        ~ (p=0.353 n=10)
Txn_unmanaged_abort-20            192.8n ± 3%   195.5n ± 3%        ~ (p=0.210 n=10)
Txn_unmanaged_commit-20           191.2n ± 4%   198.2n ± 4%        ~ (p=0.468 n=10)
Txn_unmanaged_ro-20               311.1n ± 3%   278.1n ± 2%  -10.62% (p=0.000 n=10)
Txn_renew-20                      119.5n ± 5%   119.2n ± 6%        ~ (p=0.779 n=10)
Txn_Get-20                        83.56n ± 3%   73.20n ± 3%  -12.40% (p=0.000 n=10)
geomean                           147.0n        144.0n        -2.04%

compared benchmark of txn.val pointer (like in master) and non-pointer (this update)

@AskAlexSharov AskAlexSharov merged commit 4c86898 into master Jun 13, 2024
5 checks passed
AskAlexSharov added a commit to erigontech/erigon that referenced this pull request Jun 13, 2024
Implementation of this PR in mdbx-go
erigontech/mdbx-go#142
to check CI

---------

Co-authored-by: Ilya Miheev <[email protected]>
Co-authored-by: alex.sharov <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants