Skip to content
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

Refactor priority logic. #229

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Refactor priority logic. #229

merged 1 commit into from
Jan 6, 2025

Conversation

CathalMullan
Copy link
Contributor

@CathalMullan CathalMullan commented Jan 4, 2025

Some ideas I'd like to experiment with:

  • make constrained nodes a distinct node kind, meaning they'll always run first?
  • can we move the if statements during search time to const?
  • consider calculating the maximum priority a branch can result in, meaning we can skip branches that can't override our max. (need a test to trigger this?)
  • simplify calculation, maybe just consider depth first, then length?
  • expose priority values in display?

UPDATE: Happy with our new approach. No more magic numbers.

Should really fill out the ARCHITECTURE file one of these days.

Managed to sneak in under 300 ns / 4 µs too, which is likely the last signifigant threshold we'll ever hit. (not cherry picked, I promise!)

@CathalMullan CathalMullan linked an issue Jan 4, 2025 that may be closed by this pull request
Copy link

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 189 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/delete.rs 14.86% 62 Missing and 1 partial ⚠️
src/search.rs 83.18% 25 Missing and 13 partials ⚠️
src/optimize.rs 69.23% 24 Missing ⚠️
src/state.rs 58.62% 24 Missing ⚠️
src/find.rs 48.83% 22 Missing ⚠️
src/display.rs 41.66% 8 Missing and 6 partials ⚠️
src/insert.rs 97.05% 1 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
src/errors/delete.rs 92.85% <ø> (+6.19%) ⬆️
src/lib.rs 78.04% <ø> (+9.75%) ⬆️
src/node.rs 100.00% <100.00%> (ø)
src/parser.rs 98.24% <100.00%> (-0.02%) ⬇️
src/router.rs 97.19% <100.00%> (+1.13%) ⬆️
src/sorted.rs 93.75% <100.00%> (ø)
src/insert.rs 95.92% <97.05%> (-3.13%) ⬇️
src/display.rs 63.73% <41.66%> (-7.91%) ⬇️
src/find.rs 67.54% <48.83%> (-24.23%) ⬇️
src/optimize.rs 79.45% <69.23%> (-14.74%) ⬇️
... and 3 more

Copy link

codspeed-hq bot commented Jan 4, 2025

CodSpeed Performance Report

Merging #229 will improve performances by 9.94%

Comparing 228-improve-priority-logic (0016d73) with main (31ec191)

Summary

⚡ 2 improvements
✅ 14 untouched benchmarks

Benchmarks breakdown

Benchmark main 228-improve-priority-logic Change
matchit benchmarks/wayfind 11.5 µs 10.9 µs +4.7%
path-tree benchmarks/wayfind 63.9 µs 58.1 µs +9.94%

@CathalMullan CathalMullan force-pushed the 228-improve-priority-logic branch 7 times, most recently from 8eacb17 to 03b2360 Compare January 5, 2025 17:46
@CathalMullan CathalMullan force-pushed the 228-improve-priority-logic branch from 03b2360 to 0016d73 Compare January 6, 2025 11:27
@CathalMullan CathalMullan marked this pull request as ready for review January 6, 2025 11:27
@CathalMullan CathalMullan merged commit 12308ad into main Jan 6, 2025
7 of 8 checks passed
@CathalMullan CathalMullan deleted the 228-improve-priority-logic branch January 6, 2025 11: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.

Improve priority logic
1 participant