[clang] [clang] Use SmallString in CommentBriefParser to reduce heap allocs (PR #147853)
Bogdan Vetrenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 06:39:02 PDT 2025
b0gdnv wrote:
Thanks for your review. Yes, I ran micro-benchmarks to check performance implications.
### Benchmark results (mean)
| Benchmark | Metric | New | Baseline | Δ (%) |
|------------------|--------------|------------|------------|---------|
| BM_Parse_Tiny | CPU Time | 494.7 ns | 504.8 ns | +2.0% (better) |
| | Throughput | 196.1 MB/s | 192.2 MB/s | -2.0% (better) |
| BM_Parse_Overflow | CPU Time | 650.5 ns | 688.0 ns | -5.5% (better) |
| | Throughput | 213.8 MB/s | 202.0 MB/s | +5.8% (better) |
| BM_Parse_1K | CPU Time | 2194.5 ns | 2289.0 ns | -4.1% (better) |
| | Throughput | 470.3 MB/s | 450.9 MB/s | +4.3% (better) |
| BM_Parse_4K | CPU Time | 7146.3 ns | 7321.4 ns | -2.4% (better) |
| | Throughput | 573.8 MB/s | 560.0 MB/s | +2.5% (better) |
| BM_Parse_8K | CPU Time | 13592.7 ns | 13994.3 ns | -2.9% (better) |
| | Throughput | 605.5 MB/s | 588.2 MB/s | +2.9% (better) |
| BM_Parse_32K | CPU Time | 53524.0 ns | 53229.9 ns | -0.6% (worse) |
| | Throughput | 612.6 MB/s | 615.7 MB/s | +0.5% (worse) |
You can find the benchmark source code here (not intended for commit):
https://gist.github.com/b0gdnv/fb6b33eb2129747cb0030abdfba3b2b3
Raw JSON results:
[brief_new.json](https://github.com/user-attachments/files/21163591/brief_new.json)
[brief_cur.json](https://github.com/user-attachments/files/21163593/brief_cur.json)
Let me know if you'd prefer this benchmark included somewhere more formal.
https://github.com/llvm/llvm-project/pull/147853
More information about the cfe-commits
mailing list