Repository navigation
Speed up rusi's compiler backend and build it on current nightly - #166
Merged
Merged
Conversation
Two hot paths in the compiler-backend wrapper repeated work that only depends on their input. Recording a call, signal, crypto component or crypto material asked the source map for the same span up to four times: once for the file path, once for the position and twice for the id key. span_site now resolves both ends of the callsite once and returns all three, and BodyVisitor keeps the last span it resolved, because one call is usually recorded as a usage, a crypto component and a signal in turn. matching_flow_models compared a symbol against all 185 built-in flow models, re-normalizing both the symbol and each model pattern on every comparison, and it is called several times per MIR call (source, sink, passthrough, tags, properties) and again in every data-flow iteration. The model patterns are now normalized once, the symbol once per match, the result is kept per distinct symbol for the life of the wrapper process, and the path-suffix checks no longer format a string. The fallback loop in sink_matches reads normalized pattern symbols from a cache instead of normalizing each one per call. On mini-redis, with the wrapper prebuilt on aarch64-macos and rusi's default toolchain choice (rustc 1.101.0-nightly 2026-10-15), a compiler-backend run with --dataflow security went from 21.5-22.0s to 4.4-4.7s wall time (three runs each), and with --deps --dataflow security-deps from 974s to 581s (one run each). Max RSS is unchanged and both reports are byte-identical to the previous wrapper's output. Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
rust-lang/rust#165079 (first nightly 2026-11-01, 1.101) made ty::GenericArgs a Copy handle to the interned argument list and removed the ty::GenericArgsRef alias, so the compiler-backend wrapper no longer built on current nightly: the FnDefArgs shim names GenericArgsRef in five places. build.rs gains a rusi_rustc_generic_args_handle probe, which compiles only where GenericArgs can be taken by value, and main.rs maps a local GenericArgsRef alias to whichever type the toolchain has. The README table of probed API changes lists the new cfg. The wrapper builds, passes its tests and is clippy-clean on stable 1.99.1, beta 1.100.0-beta.10 and nightly 1.101.0 (2026-11-04), and a compiler-backend run on mini-redis completes on each of them. Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
cargo update moves the one dependency that had a newer compatible release; every direct dependency is already on its latest version. Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
The report's runtime.rustc_version and runtime.cargo_version came from a bare `rustc --version` and `cargo --version`, so they named whichever toolchain was first on PATH. With --toolchain beta or nightly, or with auto (which picks the rolling nightly when one is installed), the report named stable 1.99.1 while a different compiler had produced its evidence, and cdxgen copied that into cdx:rusi:rustcVersion. The driver already reads the resolved toolchain's versions to decide whether the backend is supported. CompilerBackendPayload now carries their first lines, and the runtime info uses them when present, falling back to the PATH tools for the stable backend or when the toolchain could not be queried. JSON_ATTRIBUTE_REFERENCE.md describes the fields as they are now; it previously said rustc -Vv, which the report never contained. Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
prabhu
enabled auto-merge
November 5, 2026 05:57
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.
This pull request speeds up rusi's compiler backend, keeps the wrapper building on current nightly, and makes the report name the toolchain that produced its evidence.
The rustc wrapper repeated two kinds of work that depend only on their input. Recording a call, signal or crypto finding asked the source map for the same span up to four times, so
span_sitenow resolves both ends of a callsite once andBodyVisitorkeeps the last span it resolved, since one call is usually recorded as a usage, a crypto component and a signal in turn.matching_flow_modelscompared each symbol with all 185 built-in flow models, re-normalizing the symbol and every pattern on each comparison, several times per MIR call and again in each data-flow iteration. The patterns are now normalized once, each distinct symbol is matched once per wrapper process, and the fallback loop insink_matchesreads cached pattern normalizations. On mini-redis (aarch64-macos, wrapper prebuilt, rustc 1.101.0-nightly 2026-10-15) a run with--dataflow securitywent from 21.5-22.0s to 4.4-4.7s, and one with--deps --dataflow security-depsfrom 974s to 581s. Max RSS is unchanged and both reports are byte-identical to those of the previous wrapper.rust-lang/rust#165079 (first nightly 2026-11-01) removed
ty::GenericArgsRefand madety::GenericArgsaCopyhandle, which broke the wrapper build on nightly. A newrusi_rustc_generic_args_handleprobe inbuild.rsselects the right type, as the existing probes do for the earlier API changes, and the README table lists it.cargo updatealso moves libc to 0.2.191; every direct dependency is already on its latest release.runtime.rustc_versionandruntime.cargo_versioncame from therustcandcargofirst on PATH, so a run with--toolchain beta,nightlyorauto(which picks nightly when one is installed) reported stable 1.99.1, and cdxgen copied that intocdx:rusi:rustcVersion. The driver already queries the resolved toolchain, soCompilerBackendPayloadnow carries those versions and the runtime info uses them, falling back to the PATH tools for the stable backend.The changes were made by AI agents. On macOS arm64 and on Windows 11 ARM64 (MSVC),
cargo test --locked, the compiler-backend tests (RUSTC_BOOTSTRAP=1 cargo test -- --ignored --test-threads=1, 18 tests),cargo clippy --all-targets -- -D warningsandcargo fmt --checkpass on stable 1.99.1, and the wrapper's tests and clippy pass on 1.100.0-beta.10 and 1.101.0-nightly (2026-11-04). A compiler-backend run offixtures/vulnerable-web-appon each of the three toolchains completes on both platforms with matching counts and reports its own rustc and cargo versions. Linux was not run locally.