Repository navigation
perf(ghidra): eliminate non-ASCII search flood, compact bridge inventories, and stream JSON responses - #13305
Merged
Merged
Conversation
…ories, and stream JSON responses
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; no blocking findings remain. SummaryThe PR reduces Ghidra bridge allocations and repeated lookups, streams JSON replies, and adds checked-in Java helper tests.
Reviews (4) · Last reviewed commit: "fix(ghidra): handle CRLF line endings in..." · Reviewed by Greptile |
This was referenced Nov 22, 2026
9 of 22 tasks
This was referenced Nov 23, 2026
16 of 22 tasks
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.
Summary
Eliminates the primary CPU, memory, GC, and lookup bottlenecks inside ReaGhidraBridge.java using Data-Intensive Applications (DDIA) designs — exact predicate pre-filtering, typed compact representations before wire serialization, secondary lookup indexes, and single-pass streaming response serialization:
literalCandidateMatcher+foldAsciiCandidateChar: Eliminatesvalue.chars()IntStreamandvalue.toLowerCase(Locale.ROOT)allocations per row and stops forwarding all non-ASCII symbols/strings when the search pattern is case-insensitive ASCII (matching ECMAScript/iusimple case folding:'A'..'Z' -> +32,'\u017F' -> 's','\u212A' -> 'k').JsonObject/.deepCopy()retention inInventoryItem/FunctionEntrywith typedNameEntry,ProcedureEntry,StringEntry, and*Factsrecords, materializingJsonObjectonly for returned hits and deferringGSON.toJson(...)tie-breaking incompareInventoryto exact(address, value)ties.binaryInventorySummaryuses lightweight counters (countProcedures(),countStrings()) preserving deduplication without retaining full inventories.leafName+ sortedList<ProcedureAlias>onProcedureEntrysosearch_proceduresexecutes zeroSymbolTable.getSymbols(entryPoint)queries per search.resolveProcedureByNameuses lazyprocedureNameIndexwhen cached or directSymbolTable.getSymbols(name)/SymbolUtilities.parseDynamicName/getFunctionThunkAddresses(true)lookup when uncached.listNames/listStringsbinary-search (sliceAtAddress) when cached or query single addresses directly when uncached.SurrogateEscapingWriter): StreamsGSON.toJson(response, writer)directly intoBufferedWriterwithout allocating a full-response intermediateString."0x" + Long.toHexString(...)replacingBigIntegerformatting incanonicalAddress,ConcurrentHashMap+ precompiled regex caches for symbol/source/FS normalization,recoveredJumpTables.length > 0guard forClangNodetraversal, per-call reference-edge maps, batched batch-naming cache invalidation keepingstringInventory, cancellation checks inreferencedStrings/referencedNames/selectedValue/swiftStringLiterals, andoriginalFileBytesSha256memoization per unmodifiedFileBytes.Problem and expected behavior
search_stringsandsearch_proceduresinReaGhidraBridgeto allocateIntStreams and lowercased strings per candidate, forward every non-ASCII row across the pipe on ASCII queries, retain tens of megabytes of eager GsonLinkedTreeMaptrees for cached inventories, re-query Ghidra's symbol table inside every search and name resolution, and buffer giant JSON reply strings on the JVM heap./iu), surrogate escaping, cancellation responsiveness, and wire schemas with dramatically lower latency and heap footprint.Change and scope
+828/-191).Follow the contribution scope.
Not applicable (internal Ghidra bridge optimization within existing read-only ephemeral database and wire boundaries; no persistent/cross-run ad-hoc caches added).
Contract and boundary impact
ReaSwitchEvidenceProbe(typedJumpTableCases),ContextEvaluatorAdapter/ReaSwiftDecoderRegressions(selectedValue), surrogate escaping, and ECMAScript/iucase-folding semantics.docs/public/product-catalog.json), package, or installation impact: none.Expected effects:
Evidence and regression coverage
BridgeEditedMethodsCheck.java) and verified via an extracted Unicode/helper parity harness (GhidraParityTest.javaacross 10,027,008 code-point/surrogate checks vs Nodev24.22.1) outside Git.21.0.12.1, Nodev24.22.1, extracted harness):literalCandidateMatcher(100k mixed ASCII/non-ASCII strings): candidate hits50,200 -> 200, cold28.56 ms -> 16.00 ms, warm4.13 ms -> 2.23 ms.StringEntryvs eagerInventoryItem+stubJsonObjectbuild+sort (200k entries):75.33 ms -> 25.91 ms, retained heap82.95 MiB -> 25.54 MiB.canonicalAddress(100k):9.73 ms -> 1.23 ms.normalizedSymbolType(500k):124.54 ms -> 8.98 ms.writeResponsestreaming vs intermediateString(50k objects):23.71 ms -> 13.15 ms(eliminates full-responseString).GHIDRA_INSTALL_DIR(>= 12.2) is not installed locally, so full headless Ghidra SDK compilation (npm run verify:ghidra:bridge-sources) and live Ghidra E2E runs rely on CI (ghidra-bridge-sources.yml).For evidence-bearing changes:
Validation performed
npm run check:fast— passed (typecheck + lint cached106ms, architecture guards passed across 2944 source files)npm run test:local -- src/ghidra/*.test.ts—35/37files (1158tests) passed inside sandbox; the 2 sandbox-restricted tests (GhidraCheckpoint.test.ts,GhidraJavaProbe.test.ts) +GhidraLiteralSearch.test.tspassed3/3files (62/62tests) when run outside sandbox (37/37files,1220/1220tests total)python3 tests/fixtures/ghidraHandshakeProbe.py /opt/homebrew/opt/openjdk@21/bin/java— passed (outside sandbox)javac -Xlint:all -Werrorparity & extracted method check (10,027,008Unicode/surrogate parity checks vs Nodev24.22.1) — passed (0discrepancies)Compatibility, safety, and release
21.0.12.1handshake probe + extracted compilation/parity checks + mocked TS unit tests; live Ghidra SDK compile awaited in CI.stringInventorypreserved across symbol/comment edits while mutation-sensitive symbol/decompiler caches still invalidate per batch.Author readiness
Human owner:
Before merge
type(scope): outcome.