Skip to content

perf(col_str): Reduce heap allocations#1068

Merged
SpencerTorres merged 1 commit intoClickHouse:mainfrom
mauidude:reduce-allocations
Jun 23, 2025
Merged

perf(col_str): Reduce heap allocations#1068
SpencerTorres merged 1 commit intoClickHouse:mainfrom
mauidude:reduce-allocations

Conversation

@mauidude
Copy link
Copy Markdown
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
Copy Markdown
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