Skip to content

Move salsa event system into Zalsa #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented May 7, 2025

The existence of Database::salsa_event is incredibly annoying as a lot of internal code takes a &dyn Database solely to do event reporting where as usually a &Zalsa handle would otherwise suffice. This becomes even more annoying when mutable handles are involved as it requires some odd code structuring to avoid mutability xor shared errors, it also makes optimizations more difficult for the compiler due to dynamic dispatches it can't look through.

So this moves the trait method away to a separate callback that can be registered, and if not registered, can be skipped entirely.

Copy link

netlify bot commented May 7, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 14ae8c6
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/681b42160dbdf30008d20e93

Copy link

codspeed-hq bot commented May 7, 2025

CodSpeed Performance Report

Merging #849 will improve performances by 6.05%

Comparing Veykril:veykril/push-nkkzvzyyqwrz (14ae8c6) with master (f78a641)

Summary

⚡ 2 improvements
✅ 10 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
amortized[Input] 3.3 µs 3.1 µs +6.05%
many_tracked_structs 36.8 µs 34.7 µs +6.03%

@Veykril Veykril force-pushed the veykril/push-nkkzvzyyqwrz branch 4 times, most recently from 7ffa829 to da5a6db Compare May 7, 2025 11:15
Veykril added 2 commits May 7, 2025 13:20
This shrinks the return value from 16 to 8 bytes
@Veykril Veykril force-pushed the veykril/push-nkkzvzyyqwrz branch from da5a6db to 14ae8c6 Compare May 7, 2025 11:20
@Veykril Veykril marked this pull request as ready for review May 7, 2025 11:34
Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

I didn't do a line by line review but this looks great.

@Veykril Veykril added this pull request to the merge queue May 7, 2025
Merged via the queue into salsa-rs:master with commit cfa88e9 May 7, 2025
11 checks passed
@Veykril Veykril deleted the veykril/push-nkkzvzyyqwrz branch May 7, 2025 11:55
@github-actions github-actions bot mentioned this pull request May 7, 2025
@MichaReiser
Copy link
Contributor

Huh, I'm pretty sure I wrote one more comment but it seems it didn't make it.

Roughly, it would be nice if Storage::new could remain argument free and we would isntead have a with_event_logger mutator method. I think the challenge with this is that zalsa is wrapped in an Arc. Would it be possible to use our normal cancellation to get a reference to storage and swap the evnet handler?

@Veykril
Copy link
Member Author

Veykril commented May 7, 2025

Ye that should be doable, though do note the new constructor is new and the previous Default impl still exists

sharkdp added a commit to astral-sh/ruff that referenced this pull request May 8, 2025
## Summary

* Update salsa to pull in salsa-rs/salsa#850.
* Some refactoring of salsa event callbacks in various `Db`'s due to
salsa-rs/salsa#849

closes astral-sh/ty#108

## Test Plan

Ran `cargo run --bin ty -- -vvv` on a test file to make sure that salsa
Events are still logged.
@github-actions github-actions bot mentioned this pull request May 23, 2025
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.

2 participants