Skip to content

Approximate sizes of stack and visisted when collecting accumulated values#622

Merged
MichaReiser merged 2 commits intosalsa-rs:masterfrom
MichaReiser:small-accumulator-perf
Dec 6, 2024
Merged

Approximate sizes of stack and visisted when collecting accumulated values#622
MichaReiser merged 2 commits intosalsa-rs:masterfrom
MichaReiser:small-accumulator-perf

Conversation

@MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Dec 4, 2024

This PR uses the input-output length to approximate the number of items added to stack and reserves stack.len() additional items in visited to avoid costly resizes. This reduces the performance regression in astral-sh/ruff#14760 from 10.3% to 9%, which seems worthwhile.

The downside is that it can result in a too large stack if a query has many outputs but only few outputs or in a too large visited set if many inputs are overlapping. I think this is acceptable, considering that the data structures are short-lived.

Performance

This shows a 9% performance improvement for the accumulator benchmark.

@netlify
Copy link

netlify bot commented Dec 4, 2024

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 5314d4c
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/67502214ff59100008541079

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 4, 2024

CodSpeed Performance Report

Merging #622 will not alter performance

Comparing MichaReiser:small-accumulator-perf (5314d4c) with master (e68679b)

Summary

✅ 9 untouched benchmarks

@MichaReiser MichaReiser force-pushed the small-accumulator-perf branch from 64620e7 to 4f365da Compare December 4, 2024 09:17
@MichaReiser MichaReiser force-pushed the small-accumulator-perf branch from 4f365da to 5314d4c Compare December 4, 2024 09:34
@MichaReiser MichaReiser added this pull request to the merge queue Dec 6, 2024
Merged via the queue into salsa-rs:master with commit c2a6d62 Dec 6, 2024
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.

3 participants