Repository navigation
Copy normalized path segments in time proportional to the segment - #86
Merged
Merged
Conversation
`normpath` appended each kept segment with `append!(output, codeunits(segment))`. `append!` checks the two arrays for aliasing through `objectid`, which hashes the segment's whole parent string, so every segment cost the length of the whole path: "/" * "a/"^25_000 * "../"^25_000 (125 KB) took 1.8 s and a 1.25 MB path 47 s. `resolvereference` and `joinpath` run every path through `normpath`. Segments are now copied byte by byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #86 +/- ##
==========================================
+ Coverage 93.75% 93.89% +0.14%
==========================================
Files 5 5
Lines 416 426 +10
==========================================
+ Hits 390 400 +10
Misses 26 26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
quinnj
referenced
this pull request
Oct 22, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #80.
normpathstill took time quadratic in the path length when a path had many segments and dot segments. The cause isappend!(output, codeunits(segment)):append!checks the destination and source for aliasing viaobjectid, which hashes the segment's whole parent string. So copying each kept segment cost the length of the entire path. The allocation-growth test from #80 could not see this, because no extra memory is allocated.resolvereferenceandjoinpathboth run their result throughnormpath.Segments are now copied byte by byte (
_append_codeunits!).normpathinput (Julia 1.12)"/a/b/c/./../../g""/a/b/../c/./d/../e/f/g/../h""name.ext/./"^512(5.6 KB)"/" * "a/"^2_500 * "../"^2_500(12.5 KB)"/" * "a/"^25_000 * "../"^25_000(125 KB)"/" * "a/"^250_000 * "../"^250_000(1.25 MB)Paths without dot segments take the existing no-copy fast path and are unchanged (18 → 15 ns, within noise). Julia 1.10 shows the same per-
append!cost (measured: a 1-byteappend!from aSubStringof a 10 MB string takes ~4 ms).Verification. New test in "Path normalization boundaries and allocation growth": a 500 KB path of segments and dot segments normalizes to
"/"in under 1 s. With this change it takes milliseconds. Without it, the same test took 30.2 s and failed. Full suite passes on Julia 1.12 and 1.10.Review.
normpath(::AbstractString)is the only caller of the new helper. Its two formerappend!sites both receiveSubString{String}views ofstr.0xff/0xfecase covers that.push!aftersizehint!doesn't reallocate.--trim=safenative job's path stays resolvable.🤖 Generated with Claude Code