feat(#4752): implement sprintf in pure EO#5271
Draft
asmirnov-backend wants to merge 4 commits into
Draft
Conversation
Contributor
🚀 Performance AnalysisAll benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information. Click to see the detailed report
|
c40ad5f to
db16795
Compare
Replace the JVM/Node atom with a pure-EO `tt.sprintf` that formats %s, %d, %f, %x, %b and positional `%N$x` references, building the result from bytes via `tt.as-ascii` and `tt.is-digit`. The old Java atom is renamed to `EOsprintfDeprecated` to dodge a class-name clash with the transpiler-generated `EOsprintf`; a puzzle tracks removing it (plus `SprintfArgs` and its test) in a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the inline decimal, fixed-point and hexadecimal formatters with the reusable `as-decimal`, `as-fixed` and `as-hex` objects, leaving sprintf with only its parser and specifier dispatch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…blowup The pure-EO `walk` re-derived `format.length` and `format.slice` on every step, and both are recursive pure-EO objects, so formatting was O(n^2) in recursive-object allocation. Under the full parallel test suite this exhausted the 4G heap and sent the JVM into a GC death spiral: `EOsprintfTest` ran 5+ hours and OOMed, blowing the 6h CI cap. Hoist `format.as-bytes` and its `size` once and walk the raw bytes with the native `bytes.size`/`bytes.slice` atoms instead. `%` (0x25) never occurs inside a UTF-8 multi-byte sequence, so literal bytes copy through unchanged. The suite now runs 1371 tests with no OOM; `EOsprintfTest` drops from ~18s to ~1.3s and fits well under 256M. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
db16795 to
876be7d
Compare
Contributor
Author
|
@yegor256, could you please take a look |
Member
|
@asmirnov-backend just delete |
Delete EOsprintfDeprecated, SprintfArgs, and SprintfArgsTest now that tt.sprintf is implemented in pure EO. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6859d2b to
1378903
Compare
|
Contributor
Author
|
@yegor256 thanks, deleted EOsprintfDeprecated.java. I'd originally deprecated it plus left a puzzle to avoid too many hits-of-code in one PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Part #4752.
Reimplements
tt.sprintfin pure EO (was a JVM/Node atom), supporting%s %d %f %x %band positional%N$xreferences.walkiterates overformat.as-bytesusing the nativebytes.size/bytes.sliceatoms rather than the recursivestring.length/string.slice(which would make formatting O(n²) in allocation and exhaust the heap under the parallel test suite).%(0x25) never occurs inside a UTF-8 multi-byte sequence, so literal bytes copy through unchanged.Number/bytes rendering is delegated to the reusable converters from #5272 (
as-decimal,as-fixed,as-hex), sosprintfkeeps only its parser and specifier dispatch.The old Java atom is renamed to
EOsprintfDeprecatedto avoid a class-name clash with the transpiler-generatedEOsprintf; a@todopuzzle tracks removing it (plusSprintfArgsand its test) in a follow-up.EO tests cover all specifiers, positional refs, float truncation/padding, and error paths.