Repository navigation
perf: cache dependency refs to skip redundant registration in validate() - #1033
saquibsaifee wants to merge 4 commits into
Conversation
|
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Documentation build overview
8 files changed ·
|
|
@jkowalleck can you take a look at this PR to boost SBOM generation turn around |
Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
6f5dc72 to
e05bb2f
Compare
|
Need to look into this again, might not be adding any performance improvement at all |
…n validate() Signed-off-by: Saquib Saifee <66195765+saquibsaifee@users.noreply.github.com>
|
@jkowalleck, this PR is ready for review. |
There was a problem hiding this comment.
Heads up that this overlaps with #1006 and open PR #1007, which addresses the same Bom.validate() -> register_dependency() linear scan.
I tested both branches locally against current main (Python 3.13, test_model_bom and JSON/XML v1.6 serialization). Both produce identical serialized output and reduce BomRef.__eq__ calls during validate() at N = 4000 from 8,051,885 to 49,884.
One code note if this branch moves forward: reading self._dependencies directly in Step 0 avoids going through the property getter, and keeping Step 1's set(chain(...)) avoids the extra per-iteration .add() / .update() overhead of the Python for loop (162 ms vs 176 ms in validate() at N = 4000). test_validate_registers_dependencies_for_components_and_services here is a nice addition though, since it explicitly covers shared bom_ref deduplication across Component and Service.
Disclosure: Local container test runs and benchmark comparisons were assisted by Google Antigravity (Gemini 4 Carbon); commands and outputs were verified locally.
Description
Optimizes$O(N^2)$ to $O(N \log N)$ by eliminating redundant linear scans over $O(1)$ .
Bom.validate()fromself.dependencieswhen ensuring dependable elements are registered, directly adding missing entries while tracking seen references inChanges:
_dependencieswith active set tracking, eliminating repeated linear filter scans over the dependency collection.Affirmation