Skip to content

fix(codegen): bound instruction modifier searches to the current token - #1260

Merged
nihalpasham merged 1 commit into
NVlabs:mainfrom
paulzhng:codex/bounded-feature-scan
Sep 23, 2026
Merged

nihalpasham merged 1 commit into
NVlabs:mainfrom
paulzhng:codex/bounded-feature-scan

Conversation

@paulzhng

@paulzhng paulzhng commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Feature detection repeatedly searched the rest of the LLVM module for escaped whitespace. Large modules therefore spent quadratic time scanning ordinary instruction tokens.

before: each token searches the remaining module
 after: each token searches only up to its first ordinary delimiter

The earliest delimiter is unchanged, including escaped and Unicode whitespace. Architecture and PTX requirements keep the same meaning.

Verification

  • All 1,261 codegen tests passed on the current-main rebase, including terminal LLVM/PTX checks.
  • An independent harness compared the exact old/new functions on 6,084 delimiter and near-match cases with identical results.
  • On a synthetic 32,768-token module, the old scan took 15.0 seconds and the new scan 1.81 milliseconds. This is a local scanner measurement, not an end-to-end build-speed claim.
  • Strict Clippy, formatting and warning-free docs passed. All seven hosted workflows passed at 4953e1e1.

No issue is closed.

Avoid scanning the remaining LLVM module for each escaped whitespace delimiter. Preserve the first token boundary while eliminating quadratic feature detection on large generated modules.

Signed-off-by: Paul Zhang <paul@studio-vaai.com>
@nihalpasham
nihalpasham force-pushed the codex/bounded-feature-scan branch from 1f5a67f to 4953e1e Compare September 23, 2026 06:09
@nihalpasham nihalpasham added codegen Device code-generation pipeline (Rust MIR to IR to PTX) perf Performance of generated code or of the compiler itself labels Sep 23, 2026

@nihalpasham nihalpasham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebased this and checked the token-boundary behavior independently. All 6,084 delimiter/near-match cases agreed with the old implementation, and the large-module scan now scales linearly in the measured cases.

All 1,261 codegen tests, strict Clippy and docs pass. All seven hosted workflows passed at 4953e1e1.

No issue is closed.

@nihalpasham
nihalpasham merged commit ccaec69 into NVlabs:main Sep 23, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Device code-generation pipeline (Rust MIR to IR to PTX) perf Performance of generated code or of the compiler itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants