Skip to content

return Sc::zero() for unchanged#47

Closed
NewBornRustacean wants to merge 1 commit intoSolverForge:mainfrom
NewBornRustacean:early-return-cross_bi_incremental
Closed

return Sc::zero() for unchanged#47
NewBornRustacean wants to merge 1 commit intoSolverForge:mainfrom
NewBornRustacean:early-return-cross_bi_incremental

Conversation

@NewBornRustacean
Copy link
Copy Markdown
Contributor

Hello @blackopsrepl 😃
I was looking into the scoring side today and found a place where an early return seemed useful.

  1. Changes
    Add an early return in IncrementalCrossBiConstraint::on_insert when the changed descriptor does not affect either a and b. This avoids calling extractor_a.extract(solution) and extractor_b.extract(solution) for unrelated descriptor changes.

  2. Expected Impact
    Reduces unnecessary work in the incremental scoring hot path during local search candidate evaluation. This should help multi-descriptor problems with multiple constraints, where many entity changes may be irrelevant to a given cross-bi constraint.

@NewBornRustacean NewBornRustacean marked this pull request as ready for review May 1, 2026 09:50
@blackopsrepl
Copy link
Copy Markdown
Collaborator

Hey @NewBornRustacean, good point!

These days I was refactoring the codebase for smaller LOC per file, but didn't push it here, yet.

The code you fixed is now in:
crates/solverforge-scoring/src/constraint/cross_bi_incremental/incremental.rs

I think it's easier if you submit a new PR to the updated main branch, so you don't lose commit history. Will be happy to merge immediately.
If we could also include a minimal test proving unrelated on_insert does not call the extractors, then even better!

Closing this one - thank you!

@NewBornRustacean
Copy link
Copy Markdown
Contributor Author

yebb 👍 will open a new one with proper tests!

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