Skip to content

Do manual trait casting #922

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jun 20, 2025

This removes occurences of dyn Database internally where only the zalsas are needed for (hopefully) a perf increase.

Lastly it renames downcasting to upcasting, because thats what we are doing, dyn Database --downcast-> Concrete --upcast-->dyn CustomDatabaseTrait

Copy link

netlify bot commented Jun 20, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 70bdaef
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6889ca5cca540400073c8b42

Copy link

codspeed-hq bot commented Jun 20, 2025

CodSpeed Performance Report

Merging #922 will improve performances by 4.2%

Comparing Veykril:veykril/push-tsxunswownmm (70bdaef) with master (8b6d12b)

Summary

⚡ 1 improvements
✅ 11 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
new[Input] 8.7 µs 8.3 µs +4.2%

@Veykril Veykril force-pushed the veykril/push-tsxunswownmm branch 4 times, most recently from 2073e08 to 28acf8c Compare June 20, 2025 09:13
@Veykril
Copy link
Member Author

Veykril commented Jun 20, 2025

Benchmarks look fairly noisy again to me

@MichaReiser
Copy link
Contributor

Not sure, 5% is a bit more than usual.

@Veykril
Copy link
Member Author

Veykril commented Jun 20, 2025

Well the increase seems to stem from ingredient fetching which means its likely the IngredientCache missing being more expensive after this

@Veykril Veykril force-pushed the veykril/push-tsxunswownmm branch 2 times, most recently from 0b13ad9 to e50ed3a Compare July 29, 2025 19:00
@Veykril
Copy link
Member Author

Veykril commented Jul 29, 2025

Okay the regression came from a dumb mistake

@Veykril Veykril marked this pull request as ready for review July 29, 2025 19:03
@Veykril Veykril changed the title Do manual trait upcasting instead of downcasting Do manual trait casting Jul 29, 2025
@MichaReiser MichaReiser requested a review from ibraheemdev July 30, 2025 06:54
@Veykril Veykril force-pushed the veykril/push-tsxunswownmm branch from e50ed3a to 523d4c8 Compare July 30, 2025 07:13
@Veykril
Copy link
Member Author

Veykril commented Jul 30, 2025

Some context for reviewing aid, there are couple of noisy changes (that I could've split out into separate commits, sorry):

  • downcasting being renamed to upcasting
  • replacing dyn Database args with Zalsa/ZalsaLocal, this allows getting rid of a few dynamic dispatches, mostly concerns the macro changes

}
}

/// Upcast to a `dyn Database`.
///
/// Only required because upcasts not yet stabilized (*grr*).
/// Only required because upcasting does not work for unsized generic parameters.
Copy link
Member Author

Choose a reason for hiding this comment

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

I am quite annoyed by this but that's a limitation of Rust, a &T of T: ?Sized + SomeTrait cannot be coerced to a &dyn SomeTrait (or a supertrait) due to T possibly being an unrelated unsized type like str

@Veykril Veykril force-pushed the veykril/push-tsxunswownmm branch from f553491 to 70bdaef Compare July 30, 2025 07:31
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