Skip to content

refactor: Introduce MemoHeader to reduce monomorphization - #1142

Merged
MichaReiser merged 7 commits into
salsa-rs:masterfrom
MichaReiser:reduce-query-monomorphization
Jun 23, 2026
Merged

refactor: Introduce MemoHeader to reduce monomorphization#1142
MichaReiser merged 7 commits into
salsa-rs:masterfrom
MichaReiser:reduce-query-monomorphization

Conversation

@MichaReiser

@MichaReiser MichaReiser commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Moves configuration-independent memo validation and cycle metadata into MemoHeader to avoid monomorphization.

This does not change the size of Memo because MemoHeader has no padding (it's always 32 bytes).

Release Binary size

Metric Base Branch Difference
Stripped binary 23,189,920 B 22,430,096 B −759,824 B / −3.28%
Unstripped binary 26,479,232 B 25,674,128 B −805,104 B / −3.04%
Mach-O __text 16,110,760 B 15,403,432 B −707,328 B / −4.39%

LLVM IR

Scope Base Branch Difference
ty_python_semantic 12,484,695 lines 11,096,129 lines −1,388,566 / −11.12%
Entire ty build 35,139,488 lines 33,380,017 lines −1,759,471 / −5.01%

Testing: Passed local validation and GitHub CI.

@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 9f5e215
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6a3a389105243a0008075e40

@codspeed-hq

codspeed-hq Bot commented Jun 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 40 untouched benchmarks


Comparing MichaReiser:reduce-query-monomorphization (9f5e215) with master (a7d212d)

Open in CodSpeed

@MichaReiser
MichaReiser force-pushed the reduce-query-monomorphization branch 3 times, most recently from b957339 to 5fedd09 Compare June 19, 2026 06:22
@MichaReiser MichaReiser changed the title refactor: reduce Salsa configuration monomorphization refactor: erase configuration from memo storage Jun 19, 2026
@MichaReiser
MichaReiser force-pushed the reduce-query-monomorphization branch 11 times, most recently from 21b4c44 to baa2917 Compare June 20, 2026 12:58
@MichaReiser MichaReiser changed the title refactor: erase configuration from memo storage refactor: Introduce MemoHeader to reduce monomorphization Jun 20, 2026
@MichaReiser MichaReiser added the refactoring Code works but is messy label Jun 20, 2026
@MichaReiser
MichaReiser force-pushed the reduce-query-monomorphization branch from 846dec5 to cb5568c Compare June 20, 2026 15:57
@MichaReiser
MichaReiser marked this pull request as ready for review June 21, 2026 06:24
@MichaReiser
MichaReiser requested a review from ibraheemdev June 21, 2026 06:24

@ibraheemdev ibraheemdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A further opportunity here is to mark Memo as repr(C), allowing you to safely treat a *const Memo<C> as *const MemoHeader, and avoid the monomorphization entirely in some of the helper methods, such as provisional_status, which still rely on looking up the concrete memo type in this PR. I was able to get much larger wins on that branch by extracting some of our query execution logic into state machines as well, but I think this PR is a good first step, and it makes sense to get most of the boilerplate out of the way before making more targeted changes.

Comment thread src/function/fetch.rs Outdated
@MichaReiser
MichaReiser force-pushed the reduce-query-monomorphization branch from 22f1683 to d980ece Compare June 23, 2026 07:09
@MichaReiser
MichaReiser force-pushed the reduce-query-monomorphization branch from d980ece to 9f5e215 Compare June 23, 2026 07:41
@MichaReiser
MichaReiser enabled auto-merge June 23, 2026 07:45
@MichaReiser
MichaReiser added this pull request to the merge queue Jun 23, 2026
Merged via the queue into salsa-rs:master with commit d1a042b Jun 23, 2026
16 checks passed
@MichaReiser
MichaReiser deleted the reduce-query-monomorphization branch June 23, 2026 07:50
@github-actions github-actions Bot mentioned this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Code works but is messy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants