Skip to content

perf(col_str): Reduce heap allocations #1068

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

mauidude
Copy link
Contributor

@mauidude mauidude commented Jun 23, 2025

Summary

Reducing the amount of allocations, mostly around ColStr and Buffer.

git checkout main
go test -benchmem -run=^$ -bench ^BenchmarkColStr_DecodeColumn$ github.com/ClickHouse/ch-go/proto -race -count=25 > old.txt

git checkout reduce-allocations
go test -benchmem -run=^$ -bench ^BenchmarkColStr_DecodeColumn$ github.com/ClickHouse/ch-go/proto -race -count=25 > new.txt

go install golang.org/x/perf/cmd/benchstat@latest

benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: github.com/ClickHouse/ch-go/proto
cpu: Apple M4 Max
                       │   old.txt   │               new.txt               │
                       │   sec/op    │   sec/op     vs base                │
ColStr_DecodeColumn-16   443.4µ ± 1%   376.3µ ± 0%  -15.13% (p=0.000 n=25)

                       │   old.txt    │               new.txt                │
                       │     B/s      │     B/s       vs base                │
ColStr_DecodeColumn-16   70.98Mi ± 1%   83.63Mi ± 0%  +17.82% (p=0.000 n=25)

                       │   old.txt    │               new.txt                │
                       │     B/op     │    B/op      vs base                 │
ColStr_DecodeColumn-16   15.62Ki ± 0%   0.00Ki ± 0%  -100.00% (p=0.000 n=25)

                       │   old.txt   │               new.txt                │
                       │  allocs/op  │  allocs/op   vs base                 │
ColStr_DecodeColumn-16   1.000k ± 0%   0.000k ± 0%  -100.00% (p=0.000 n=25)

Checklist

Delete items not relevant to your PR:

  • A human-readable description of the changes was provided to include in CHANGELOG

@mauidude mauidude force-pushed the reduce-allocations branch from 0ede5f8 to 1bdde09 Compare June 23, 2025 22:40
@mauidude mauidude marked this pull request as ready for review June 23, 2025 22:43
Copy link
Member

@SpencerTorres SpencerTorres left a comment

Choose a reason for hiding this comment

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

Excellent 👌

@SpencerTorres SpencerTorres merged commit caa667f into ClickHouse:main Jun 23, 2025
19 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