Visitar URL original
Faster String#dump, #scrub and #codepoints on ASCII-heavy strings by sampokuokkanen · Pull Request #9975 · jruby/jruby · GitHub
Skip to content

Faster String#dump, #scrub and #codepoints on ASCII-heavy strings - #9975

Merged
headius merged 6 commits into
jruby:masterfrom
sampokuokkanen:string-ascii-fastpaths
Nov 3, 2026
Merged

headius merged 6 commits into
jruby:masterfrom
sampokuokkanen:string-ascii-fastpaths

Conversation

@sampokuokkanen

@sampokuokkanen sampokuokkanen commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Ports a few of @FletcherDares' string fast paths from CRuby:

I also dropped Sprintf from dump's escape path. It now writes the hex digits straight into the buffer, which was the main cost for non-ASCII input.

Numbers on Apple M1 Pro, JDK 21, i/s:

before after
dump, 4.6 KB ASCII 51k 313k
dump, UTF-8 2.8k 6.7k
dump, binary non-ASCII 57k 353k
scrub, mostly ASCII with a bad byte 204k 1038k
codepoints, mostly ASCII UTF-8 39k 69k

Output is byte-identical to master on a few thousand random strings across several encodings.

@headius headius added this to the JRuby 10.1.3.0 milestone Nov 3, 2026

@headius headius 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.

Only minor changes. Thanks!

@headius headius 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.

Thanks for the review changes!

@headius
headius merged commit 6ed87d9 into jruby:master Nov 3, 2026
146 checks passed
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.

2 participants