You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PERF] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency() linear scan #1006
cyclonedx-python-lib9.1.0 (the offending code path is unchanged on main / 11.x)
Python 3.10, Linux
Description
Serializing a BOM with many components scales quadratically with the number of components, not linearly. For a container SBOM with several thousand components, output_as_string() stalls for minutes, almost entirely inside Bom.validate().
Called once per component over the growing dependency collection, this is O(N²) overall.
Proposed fix
Replace the linear lookup with an indexed (dict[ref -> Dependency]) lookup. In a local benchmark an indexed variant produces byte-identical output and gives ~8x speedup at N=6000 (the gap widens with N). I'm happy to open a PR with the fix and a regression/scaling test.
changed the title [-][BUG] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/-][+][PERF] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/+]on Jun 24, 2026
changed the title [-][PERF] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/-][+][PERF] Quadratic (O(N^2)) serialization time for large BOMs — `Bom.validate()` → `register_dependency()` linear scan[/+]on Jun 24, 2026
The limitations of the existing model.bom.Bom.validate() implementation are already known, and a broader rework is planned — see #455. Because this touches a module with several structural weaknesses, addressing it properly will require coordination and may take some time.
A complete solution is therefore unlikely to land immediately, but your input is valuable and will help shape the upcoming redesign. In the meantime, we’ll track this as part of the ongoing effort to improve the validation workflow.
That said, small, well‑scoped pull requests that provide incremental improvements are very welcome. Targeted fixes, refactorings, or test enhancements that move the module in the right direction - without attempting to solve the entire redesign at once - are much easier to review and integrate.
Activity
[-][BUG] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/-][+][PERF] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/+]jkowalleck commentedon Jun 24, 2026
related: #935
[-][PERF] Quadratic (O(N^2)) serialization time for large BOMs — Bom.validate() → register_dependency linear scan[/-][+][PERF] Quadratic (O(N^2)) serialization time for large BOMs — `Bom.validate()` → `register_dependency()` linear scan[/+]jkowalleck commentedon Jun 24, 2026
Thank you for the detailed report.
The limitations of the existing
model.bom.Bom.validate()implementation are already known, and a broader rework is planned — see #455. Because this touches a module with several structural weaknesses, addressing it properly will require coordination and may take some time.A complete solution is therefore unlikely to land immediately, but your input is valuable and will help shape the upcoming redesign. In the meantime, we’ll track this as part of the ongoing effort to improve the validation workflow.
That said, small, well‑scoped pull requests that provide incremental improvements are very welcome. Targeted fixes, refactorings, or test enhancements that move the module in the right direction - without attempting to solve the entire redesign at once - are much easier to review and integrate.