Skip to content

perf: avoid copying YCSB latency slices in final reports - #273

Merged
ovaistariq merged 2 commits into
mainfrom
perfloop-pr-open-wzp2r1qphe
Sep 9, 2026
Merged

ovaistariq merged 2 commits into
mainfrom
perfloop-pr-open-wzp2r1qphe

Conversation

@perfloop

@perfloop perfloop Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

GetPerOperationStats copies every per-operation latency slice before sorting percentile values. The final report runs after the YCSB workers finish, so this copy is avoidable.

Fix

Take the collector's exclusive lock while final statistics are computed and sort each owned latency slice in place. Counts, errors, averages, and percentiles stay unchanged; the collector's internal latency order remains private. The exclusive lock serializes recording with report generation, which is covered by the concurrent test.

Add YCSB tests and benchmarks for statistic preservation and the complete RunYCSBWithContext path at 1K, 100K, and 1M operations. The benchmark profiles allocation through the real final report and times the statistics step instead of using a synthetic display fixture. An unexported hook defaults to the existing statistics method and is used only by the same-package benchmark.

Verification

  • make lint
  • make install-protoc-plugins && PATH="$(go env GOPATH)/bin:$PATH" make test-client TESTFLAGS='-race'
  • make license-check

Workload: ordinary read-only YCSB final report at cfg.NumOps=1K with one-byte values; per-report alloc_space attributed to GetPerOperationStats

Metric Before After Change
report_alloc_space_bytes 9000 808 91% lower

Workload: ordinary read-only YCSB final report at cfg.NumOps=100K with one-byte values; per-report alloc_space attributed to GetPerOperationStats

Metric Before After Change
report_alloc_space_bytes 820008 808 99.9% lower
Checks: 3 passed.

Generated by Perfloop. Measurements and checks.


Note

Low Risk
YCSB benchmark metrics only; behavior is preserved with added concurrency coverage, and production use is effectively post-run final reporting.

Overview
GetPerOperationStats no longer copies each per-operation latency slice before computing percentiles. It takes an exclusive lock, sorts the collector’s owned slices in place, and documents that internal slice order is not part of the public contract. Reported counts, errors, averages, and percentiles are unchanged; large final reports see much lower allocation (per PR measurements).

Adds metrics_test.go: correctness tests (including repeated calls and concurrent record vs. stats), plus benchmarks for GetPerOperationStats, full RunYCSBWithContext final reporting, and DisplayFinalResultsWithMetrics at 1K–1M ops.

progress_pterm.go routes the final per-operation table through a same-package getPerOperationStatsForReport hook (defaults to GetPerOperationStats) so benchmarks can time the real stats step without changing output.

Reviewed by Cursor Bugbot for commit 121d148. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no actionable correctness, concurrency, security, or repository-rule violations identified.

Summary

  • Preserves operation counts, errors, averages, and latency percentiles.
  • Adds correctness and concurrency coverage for statistics collection.
  • Adds benchmarks for statistics generation, final reporting, and the complete YCSB execution path.
  • Introduces a same-package benchmark hook to time final-report statistics without changing report output.

@ovaistariq
ovaistariq merged commit 10c84e3 into main Sep 9, 2026
9 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-wzp2r1qphe branch September 9, 2026 20:45
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants