Performance: only check independence for filled component scenarios#1368
Performance: only check independence for filled component scenarios#1368TonyXiang8787 merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes update-independence checking by iterating only over scenarios that actually contain component data (“filled scenarios”), avoiding unnecessary per-scenario work when a component is absent/empty in the batch.
Changes:
- Replaced “all scenarios” buffer-span APIs with “filled scenarios” variants and updated call sites accordingly.
- Updated independence checking to use filled-scenario spans (with early-outs) instead of scanning every scenario.
- Adjusted unit tests to validate the new filled-scenario span behavior for row-based and columnar datasets.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/cpp_unit_tests/test_dataset.cpp |
Updates tests to validate filled-scenario span enumeration instead of all-scenario enumeration. |
power_grid_model_c/power_grid_model/include/power_grid_model/main_core/update.hpp |
Uses filled-scenario spans to reduce work during independence checks. |
power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/dataset.hpp |
Introduces filled-scenario span views and refactors span retrieval helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@mgovers can you put some demostrative example in your PR description to show what exactly is improved? By looking at code change it is not that clear. |
… data Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com> fix compilation Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com> resolve copilot comments Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com> some cleanup regarding filtering distance overhead Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com> partial revert and go down a different route Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
8da13e4 to
2107db7
Compare
done |
|



In the current main, for every component, every scenario in a batch was checked to determine the update independence, even if there are no components of that type in the entire batch. That is, of course, not needed.
This PR changes the iteration over all scenarios to an iteration over all filled scenarios. This is much more efficient. In particular, there is an early-out if there are no components of a type in the update dataset, and another one if the batch update is not uniform for that component.
Test
Script
Current main
All the different components all take up some amount of time in the calculations. While small for one component, the sheer amount of component types adds up. This is even more so for large batch calculations

This branch
Only the source component (the only component that is updated in the update data) has any significant time being spent on
