Skip to content

Small performance improvement of flags (RI) - #304

Merged
jquast merged 3 commits into
masterfrom
jq/quadratic-reverse-RIs
Oct 24, 2026
Merged

jquast merged 3 commits into
masterfrom
jq/quadratic-reverse-RIs

Conversation

@jquast

@jquast jquast commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Use the same UB stance that is used for ZWJ: RI's are placed in pairs so we can more simply track ri_unpaired, and ri_unpaired_before to more rapidly determine RI pairs. This means it might get it "wrong" for invalid unicode sequences, like combining characters with RI's, but we don't care to try measure about that correctly.

@codspeed

codspeed Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by ×5.6

1 warning

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 8 improved benchmarks
✅ 129 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_wcswidth_ri_flags_paired 432.3 µs 35.4 µs ×12
⚡ test_width_ri_flags_paired 438.1 µs 41 µs ×11
⚡ test_wcstwidth_ri_term_program[ghostty] 471.8 µs 74.1 µs ×6.4
⚡ test_width_ri_term_program[ghostty] 476.7 µs 79.2 µs ×6
⚡ test_wcswidth_ri_flags_unpaired 129 µs 32 µs ×4
⚡ test_width_ri_flags_unpaired 132.8 µs 36 µs ×3.7
⚡ test_wcstwidth_ri_term_program[xterm.js] 554.1 µs 156.4 µs ×3.5
⚡ test_width_ri_term_program[xterm.js] 559.1 µs 161.4 µs ×3.5

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jq/quadratic-reverse-RIs (4417107) with master (2a8edf1)

Open in CodSpeed

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.12%. Comparing base (2a8edf1) to head (4417107).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   88.09%   88.12%   +0.02%     
==========================================
  Files          41       41              
  Lines        5654     5632      -22     
  Branches     1520     1508      -12     
==========================================
- Hits         4981     4963      -18     
+ Misses        319      318       -1     
+ Partials      354      351       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jquast jquast changed the title Improve backwards grapheme performance over RI Small performance improvement of flags (RI) Oct 24, 2026
@jquast
jquast marked this pull request as ready for review October 24, 2026 20:32
@jquast
jquast merged commit 723e83b into master Oct 24, 2026
38 checks passed
@jquast
jquast deleted the jq/quadratic-reverse-RIs branch October 24, 2026 21:18
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.

1 participant