Skip to content

Cursor.Put: doesn't have bench, but has heap-pointer cgo overhead#205

Merged
JkLondon merged 15 commits intomasterfrom
alex/reduce_bufio_34
Jan 25, 2026
Merged

Cursor.Put: doesn't have bench, but has heap-pointer cgo overhead#205
JkLondon merged 15 commits intomasterfrom
alex/reduce_bufio_34

Conversation

@AskAlexSharov
Copy link
Collaborator

@AskAlexSharov AskAlexSharov commented Jan 25, 2026

go test -benchmem -bench=BenchmarkCursor_Set_Sequence -run=BenchmarkCursor_Put_Sequence -benchtime=200ms -count=5 -cpuprofile=cpu.out ./mdbx
go tool pprof -http=:8080 cpu.out
Screenshot 2026-01-25 at 09 08 05

@AskAlexSharov AskAlexSharov changed the title Cursor.Put doesn't have bench but has cgo overhead Cursor.Put: doesn't have bench, but has heap-pointer cgo overhead Jan 25, 2026
@AskAlexSharov
Copy link
Collaborator Author

I understand what pointer it is: Cursor
we pass c._c pointer to cursor to C. So tx.Put has less CGO overhead than c.Put:

go test -benchmem -bench=BenchmarkCursor_Put_Sequence -run=BenchmarkCursor_Put_Sequence -benchtime=200ms -count=5 -cpuprofile=cput.out ./mdbx
goos: linux
goarch: amd64
pkg: github.com/erigontech/mdbx-go/mdbx
cpu: AMD EPYC 4344P 8-Core Processor
BenchmarkCursor_Put_Sequence-16    	   24308	      9847 ns/op	       0 B/op	       0 allocs/op
BenchmarkCursor_Put_Sequence-16    	   24009	      9956 ns/op	       0 B/op	       0 allocs/op
BenchmarkCursor_Put_Sequence-16    	   24308	      9846 ns/op	       0 B/op	       0 allocs/op
BenchmarkCursor_Put_Sequence-16    	   24084	      9963 ns/op	       0 B/op	       0 allocs/op
BenchmarkCursor_Put_Sequence-16    	   24274	      9924 ns/op	       0 B/op	       0 allocs/op

 go test -benchmem -bench=BenchmarkTxn_Put_Sequence -run=BenchmarkTxn_Put_Sequence -benchtime=200ms -count=5 -cpuprofile=txput.out ./mdbx
goos: linux
goarch: amd64
pkg: github.com/erigontech/mdbx-go/mdbx
cpu: AMD EPYC 4344P 8-Core Processor
BenchmarkTxn_Put_Sequence-16    	   37184	      6314 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxn_Put_Sequence-16    	   38715	      6170 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxn_Put_Sequence-16    	   38653	      6207 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxn_Put_Sequence-16    	   38214	      6274 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxn_Put_Sequence-16    	   38389	      6227 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/erigontech/mdbx-go/mdbx	1.204s

@AskAlexSharov
Copy link
Collaborator Author

@JkLondon JkLondon merged commit c1535b4 into master Jan 25, 2026
16 checks passed
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