Skip to content

[dnm] benchmark and optimize gtid#25

Open
grodowski wants to merge 5 commits intomasterfrom
benchmark-gtid
Open

[dnm] benchmark and optimize gtid#25
grodowski wants to merge 5 commits intomasterfrom
benchmark-gtid

Conversation

@grodowski
Copy link
Member

@grodowski grodowski commented Mar 4, 2026

Before:

❯ go test ./go/binlog/ -run='^$' -bench=BenchmarkStreaming -benchmem -benchtime=5s -v
goos: darwin
goarch: arm64
pkg: github.com/github/gh-ost/go/binlog
cpu: Apple M3 Pro
BenchmarkStreamingGTID
GTID (182 UUIDs)               done (1 iters)
GTID (182 UUIDs)               done (100 iters)
GTID (182 UUIDs)               done (10000 iters)
GTID (182 UUIDs)               done (13946 iters)
BenchmarkStreamingGTID-11    	   13946	    433638 ns/op	  567269 B/op	    7360 allocs/op
BenchmarkStreamingFile
File                           done (1 iters)
File                           done (100 iters)
File                           done (10000 iters)
File                           done (13101 iters)
BenchmarkStreamingFile-11    	   13101	    455612 ns/op	  160392 B/op	    2734 allocs/op
PASS
ok  	github.com/github/gh-ost/go/binlog	21.718s

After:

❯ go test ./go/binlog/ -run='^$' -bench=BenchmarkStreaming -benchmem -benchtime=5s -v
goos: darwin
goarch: arm64
pkg: github.com/github/gh-ost/go/binlog
cpu: Apple M3 Pro
BenchmarkStreamingGTID
GTID (182 UUIDs)               done (1 iters)
GTID (182 UUIDs)               done (100 iters)
GTID (182 UUIDs)               done (10000 iters)
BenchmarkStreamingGTID-11    	   10000	    549252 ns/op	  188160 B/op	    3261 allocs/op
BenchmarkStreamingFile
File                           done (1 iters)
File                           done (100 iters)
File                           done (10000 iters)
File                           done (13216 iters)
BenchmarkStreamingFile-11    	   13216	    456533 ns/op	  159648 B/op	    2707 allocs/op
PASS
ok  	github.com/github/gh-ost/go/binlog	16.880s

// GTIDBinlogCoordinates. The result is an independent snapshot safe to hold across
// transaction boundaries. This is the only point where a MysqlGTIDSet.Clone occurs.
func (l *LazyGTIDCoordinates) Materialize() *GTIDBinlogCoordinates {
set := l.base.Clone().(*gomysql.MysqlGTIDSet)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could even cache &GTIDBinlogCoordinates{GTIDSet: set} of this so we don't call Clone() if we're materializing the same gtid more than once.

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