perf: accelerate printable ASCII text width - #297
Conversation
Use a boolean byte reduction before the existing ANSI parser and width composition. Preserve control and Unicode fallback behavior. Co-Authored-By: Aiden <aiden@weco.ai>
djc
left a comment
There was a problem hiding this comment.
Did this actually show up as some kind of bottleneck in your application?
Move the four text width regression fixtures beside the existing unit tests without changing the measured implementation or assertions. Co-Authored-By: Aiden <aiden@weco.ai>
|
This came from benchmarking the public I tried I've moved the four regression tests into |
Bumps console from 0.16.4 to 0.16.6. Release notes Sourced from console's releases. 0.16.6 What's Changed Fix truncate_str panicking mid-character without ansi-parsing by @lenamonj in console-rs/console#296 perf: accelerate printable ASCII text width by @dexhunter in console-rs/console#297 fix: measure the truncation tail in visible columns, not raw width by @youdie006 in console-rs/console#298 Prepare 0.16.6 by @djc in console-rs/console#299 0.16.5 What's Changed Strip OSC and DCS sequences to support e.g. OSC 8 hyperlinks over tmux. by @khoek in console-rs/console#280 Commits 4329b77 Bump version to 0.16.6 bdf46b0 utils: wrap tests in module 4f54213 fix: measure the truncation tail in visible columns ed342d0 test: consolidate text width regression coverage 48b99e9 perf: accelerate printable ASCII text width abf0358 Fix truncate_str panicking mid-character without ansi-parsing ac3cb73 Bump version to 0.16.5 97a91ae ansi: strip OSC and DCS sequences See full diff in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
measure_text_widthcurrently runs printable ASCII through ANSI parsing and width calculation. This adds a boolean byte reduction that returns the byte length for printable ASCII when ANSI parsing is enabled. Other inputs retain the existing parser and width behavior.On Rust 1.97.1 / Linux x86_64, a fixed five-corpus public-API microbenchmark improved from 320.91 ns to 90.79 ns (71.7% lower); a separate winner replay measured 90.58 ns. The mix includes three ASCII corpora, Unicode status text and colored status text. The latter two cases were about 7.0% and 2.8% slower, respectively; all eight fallback/tiny regression guards passed. These are function-latency measurements.
Validation passed all seven native feature configurations, formatting, clippy, release build and docs. Four added regression tests passed on both pristine and candidate code, and the evaluator checked 3,434,040 semantic cases in each of four ANSI/Unicode feature combinations.
The external autoresearch trajectory and exact source/metric bindings are available in Weco Observe.
The measurements and Observe source snapshots correspond to research commit
13501c50490950db912aa6cdba672825939708e1. Follow-up commitb63f12304da138f3ba40c9a56de858a2a057c485only moves the same four regression tests intosrc/utils.rs; the measured implementation is unchanged. The seven feature configurations, formatting, clippy, release build and docs were validated again for this revision. The benchmark was not motivated by an application profile.