Repository navigation
perf(extraction): compute a call's URL context once, and only when read - #2621
Merged
Merged
Conversation
#2513 (77bc492) computes `url_context` -- is the callee an HTTP client or a global fetch? -- for every positional argument of every call, in every language, through cbm_service_pattern_match: a linear strstr over every service pattern. Only the URL-folding functions read it, and they return NULL outside Python and JS/TS; the one other reader is the template-string branch. On the C# corpus (dotnet/runtime, 451k functions) extraction went from 24.7 s to 37.4 s (+51 %); a macOS sample put the difference in handle_calls -> cbm_service_pattern_match -> match_qn -> strstr. A per-call url_context_t now computes the answer at most once and only when an argument needs it: the folding paths ask only in folding languages, the template-string branch asks for itself. Proof (macOS arm64, Apple M5 Pro): - C# parallel_extract 37.4 s -> 24.2 s, wall 127-132 s -> 119.7 s (the pre-#2513 level, 24.7 s / 121.9 s). - Byte-identical graphs: the full node and edge sets (properties included) hash the same before and after on django (Python), typescript (TS) and csharp, HTTP_CALLS included (457 / 283 / 39). - extraction, extraction_imports, pipeline, parallel, infrascan and edge_types_probe: 1009 passed. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.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.
Tonight's bench of the final release tree (10 LSP corpora, three interleaved runs each, plus the kernel) found csharp 10 % slower than this morning's main (135.5 s against 123.4 s, all three runs consistent).
A per-pass trace put the whole difference in
parallel_extract: 24.0 s → 37.6 s. Bisecting over the merge batches pinned it to #2513's first commit (77bc492). A macOSsamplediff showed the cost inhandle_calls → cbm_service_pattern_match → match_qn → strstr.Cause
extract_url_or_topic_argcomputesurl_context(is the callee an HTTP client or a global fetch?) once per positional argument of every call, in every language, through a linearstrstrscan over all service patterns. Only the URL-folding functions read the answer, and they return NULL outside Python and JS/TS. The one other reader is the template-string branch.Fix
A per-call
url_context_tcomputes the answer at most once, and only when an argument reads it. The folding paths ask only in folding languages; the template-string branch asks for itself.Proof (macOS arm64)
parallel_extract37.4 s → 24.2 s, wall 127–132 s → 119.7 s. Before Preserve topic identities while folding local URL constants #2513 it was 24.7 s / 121.9 s.extraction,extraction_imports,pipeline,parallel,infrascanandedge_types_probe: 1009 passed.