Skip to content

perf: avoid type checks in memo and field lookups - #1174

Draft
MichaReiser wants to merge 12 commits into
salsa-rs:masterfrom
MichaReiser:optimize-memo-lookup
Draft

perf: avoid type checks in memo and field lookups#1174
MichaReiser wants to merge 12 commits into
salsa-rs:masterfrom
MichaReiser:optimize-memo-lookup

Conversation

@MichaReiser

@MichaReiser MichaReiser commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Memo and field lookups repeated TypeId checks even though the database-bound ingredient fixes the accessed type. Bind each ingredient to its database context and acquire thread-local state only for operations that need it.

Fixed hot memo hits drop from 233 to 228 instructions (-2.15%), untracked tracked-struct field bodies drop from 59 to 58, CodSpeed reports a 6.76% aggregate improvement, and ty's 29-case suite improves by 0.145% weighted overall.

Testing: Full target, manual-registration, lint, and performance suites passed.

@netlify

netlify Bot commented Jun 21, 2026

Copy link
Copy Markdown

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 1ff4965
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6a4ffb9048b8850008ed90bf

@codspeed-hq

codspeed-hq Bot commented Jun 21, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 9.6%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 5 regressed benchmarks
✅ 69 untouched benchmarks
⏩ 1 skipped benchmark1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime parallel_fast_path[NoEviction] 361.3 µs 419.9 µs -13.96%
WallTime project_check_then_incremental[NoEviction] 6.1 ms 6.8 ms -11.11%
WallTime parallel_fast_path[Lru] 3.8 ms 4.2 ms -9.87%
WallTime project_check_then_incremental[Lru] 10 ms 10.9 ms -8.75%
WallTime scan_resistance[NoEviction] 836.8 µs 872 µs -4.03%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing MichaReiser:optimize-memo-lookup (1ff4965) with master (25ed9d3)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@MichaReiser

Copy link
Copy Markdown
Contributor Author

This is cool but I don't think codex's reasoning here is safe. The issue is that zalsa could be smuggled in. So we'd have to make fetch unsafe.

@MichaReiser
MichaReiser force-pushed the optimize-memo-lookup branch from ae9fb41 to 4b76b1d Compare June 22, 2026 09:22
@MichaReiser
MichaReiser force-pushed the optimize-memo-lookup branch 2 times, most recently from 6d04b76 to e16c18e Compare June 30, 2026 19:54
@MichaReiser MichaReiser changed the title perf: avoid type check in memo lookup perf: avoid type checks in memo and field lookups Jul 5, 2026
@MichaReiser
MichaReiser force-pushed the optimize-memo-lookup branch from 7045e87 to 1ff4965 Compare July 9, 2026 19:50
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