Skip to content

Performance optimizations - #258

Open
lm-sousa wants to merge 1 commit into
syntax-rebuild-optimizationfrom
clava-optimizations
Open

Performance optimizations#258
lm-sousa wants to merge 1 commit into
syntax-rebuild-optimizationfrom
clava-optimizations

Conversation

@lm-sousa

@lm-sousa lm-sousa commented Sep 4, 2026

Copy link
Copy Markdown
Member

Stacked on #257 (only shows this commit until that merges).

Inliner.renameLabels() ran two whole-AST Query.search() passes for every inlined call — walking the entire program to rename labels that all live inside the copied body, even though the method already receives the complete $newNodes copy. The parameter has been unused since the feature's introduction (referenced only in a commented-out println), and the earlier triage attributed ~9 s of Query time to it.

This scopes both searches with Query.searchFrom($newNodes, …) — the same proven pattern the method already uses for forward declarations. Renaming runs on the detached body copy before insertion, where cross-function gotos cannot exist, so every goto/label pair stays consistently matched. As a side effect it stops renaming labels inside functions that were never inlined and eliminates a latent replaceWith(undefined) on labels with no map entry; labels that clang's return-lowering attaches to the caller's own body now keep their original name, and each inlined copy carries its own renamed set, so no duplicate-label collision is possible.

The InlinerTest goldens were regenerated: label numbering is now per-inline sequential (inliner_0_, inliner_1_) instead of driven by the whole-AST counter; the diff touches label lines only.

Part of the step-2 change set measured with the syntax-rebuild revisions: suite median 111.79 s → 47.60 s (the SpecsSystem half of that step is in specs-java-libs#32).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e09012a63f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Clava-JS/api/clava/code/Inliner.ts
@lm-sousa
lm-sousa force-pushed the clava-optimizations branch from e09012a to e08d307 Compare September 4, 2026 23:53
@lm-sousa lm-sousa changed the title perf: scope Inliner label renaming to the inlined nodes Performance optimizations Sep 4, 2026
@lm-sousa
lm-sousa force-pushed the clava-optimizations branch 2 times, most recently from 6b98c31 to 518bfff Compare September 5, 2026 00:15
renameLabels() searched the whole AST for every inline even though
the $newNodes parameter it received (unused since fa56385) already
contains the complete copied body. Scope both searches with
Query.searchFrom($newNodes, ...), which also stops renaming labels of
unrelated functions and removes a latent replaceWith(undefined) on
labels with no map entry.

Regenerate InlinerTest goldens: label numbering is now per-inline
sequential (inliner_0_, inliner_1_) instead of driven by the global
whole-AST counter.
@lm-sousa
lm-sousa force-pushed the clava-optimizations branch from 518bfff to 70c30bd Compare September 6, 2026 03:18
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant