Skip to content

POT serialization optimization (with 87% improvement) - #1789

Merged
tompng merged 1 commit into
ruby:masterfrom
skatkov:pot-serialization-optimization
Aug 26, 2026
Merged

POT serialization optimization (with 87% improvement)#1789
tompng merged 1 commit into
ruby:masterfrom
skatkov:pot-serialization-optimization

Conversation

@skatkov

@skatkov skatkov commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

String#+ creates a new string and copies everything accumulated so far. Repeating that for tens of thousands of entries is quadratic.

I replaced the repeated concatenation with one join.

Benchmark results for a 400-file build have significantly improved:

  • Before: 104.29s
  • After: 13.21s
  • Improvement: 87.3%

Output in both cases is identical

Benchmark

Created git repo with the benchmark at rdoc-pot-serialization-benchmark.

  • bin/benchmark: isolated serialization, up to 566x faster
  • bin/benchmark-google: end-to-end, 201.73s → 18.32s, identical output, up to 11x faster

String#+ creates a new string and copies everything accumulated so far. Repeating that for tens of thousands of entries is quadratic.

I replaced the repeated concatenation with one join and results of 400-file build have significantly improved:
- Before: 104.29s
- After: 13.21s
- Improvement: 87.3%
- Output size: identical
- SHA-256: identical
Copilot AI balanced review requested due to automatic review settings August 26, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@skatkov
skatkov deployed to fork-preview-protection August 26, 2026 12:46 — with GitHub Actions Active

@tompng tompng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch 👍

@tompng
tompng merged commit 482328f into ruby:master Aug 26, 2026
29 checks passed
@matzbot

matzbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

🚀 Preview deployment available at: https://b5779b1d.rdoc-6cd.pages.dev (commit: 81fe6fb)

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.

4 participants