Skip to content

Go: reduce intermediate tuples in embedded method resolution - #22995

Open
owen-mc wants to merge 1 commit into
github:mainfrom
owen-mc:go/fix-dca-tuple-sum-noise-2
Open

owen-mc wants to merge 1 commit into
github:mainfrom
owen-mc:go/fix-dca-tuple-sum-noise-2

Conversation

@owen-mc

@owen-mc owen-mc commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

StructType.getMethodOfEmbedded could join methods with types of all fields before filtering to embedded fields, producing large intermediate relations.

Materialize embedded fields and their types in a private helper before joining them with methods. Mark the helper nomagic to preserve this small intermediate relation.

On the AWS SDK database, this reduces tuple sums by approximately 93%:

Computation Before After
Broad lookup 24,726,227 1,905,099
Restricted lookup 3,759,483 277,538

These distinct staged computations can receive the same DCA reporting key: shared-work attribution can change, while DCA strips RA hashes and omits singleton stage suffixes. This optimization does not fix that reporting issue, but substantially reduces the work involved. Across three full-suite runs, all corresponding entries were below DCA’s 10-million-tuple reporting threshold.

@owen-mc owen-mc added the Go label Nov 3, 2026
Materialize embedded fields and their types before joining them with methods. Keep the helper non-inline and non-magic to avoid expanding field-type lookups across all fields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@owen-mc
owen-mc force-pushed the go/fix-dca-tuple-sum-noise-2 branch from e12788e to e1083dd Compare November 3, 2026 12:58
@owen-mc

owen-mc commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

DCA shows a reduction in tuple count for the intended predicate and no significant change in overall analysis time.

@owen-mc
owen-mc marked this pull request as ready for review November 3, 2026 13:57
@owen-mc
owen-mc requested a review from a team as a code owner November 3, 2026 13:57
Copilot AI auto review requested due to automatic review settings November 3, 2026 13:57
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Nov 3, 2026
@owen-mc
owen-mc requested a review from hvitved November 3, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the embedded-method resolution optimization.

No open issues 🎉

What changed in this PR

This PR optimizes Go embedded-method resolution by filtering embedded fields and their types before joining them with methods, reducing intermediate tuples without changing lookup semantics.

Changes:

  • Adds a private nomagic helper to materialize embedded fields and their types.
  • Updates getMethodOfEmbedded to use the smaller relation for method lookup.
File Description
go/​ql/​lib/​semmle/​go/​Types.qll Separates embedded-field filtering from method joins to reduce intermediate computation.

Review effort: Balanced (auto)

This branch has not been deployed

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

Labels

Go no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants