bullet3-0001: btGhostObject::addOverlappingObjectInternal O(N²) linear dedup per broadphase step — even carries "too slow" self-admission comment (HIGH) bullet3-0002: btSoftRigidCollisionAlgorithm::processCollision O(C×D) per frame on m_collisionDisabledObjects plain array (MEDIUM) allegro5: CLEAN (vector_contains only on non-hot setup paths) box2d: CLEAN (v3 rewrite uses b2HashSet throughout) dry: CLEAN (HashSet/HashMap on all hot dedup paths)
2 KiB
2 KiB
CLEAN — Ceph Distributed Storage
Scanned 2026-03-29 for CWE-407 (algorithmic complexity: O(N²) linear membership tests, O(2^D) diamond recursion).
Scope
src/crush/CrushWrapper.cc— CRUSH placement algorithmsrc/crush/mapper.c— CRUSH mappersrc/osd/OSDMap.cc— OSD map and PG upmap balancingsrc/osd/PeeringState.cc— PG peering and acting set selectionsrc/osd/PrimaryLogPG.cc— primary log, snapshot clone operationssrc/mon/OSDMonitor.cc— monitor OSD management
Findings
CrushWrapper.ccrebalancing —std::findonorig(PG placement output vector, size = replication_factor, typically 3–8). Outer loop is overunderfullOSD candidates. Inner find is O(replication_factor) = O(constant). Not scalable O(N²). CLEAN.OSDMap.ccpg_upmap moved-count tracking —std::findonup2(replication_factor entries). O(constant) inner. CLEAN.OSDMap.ccunderfull candidate scan —std::findonunderfulllist; both loops are over OSD deviation_osd list × underfull list. In practice bounded by OSD count (~hundreds) × replication_factor. Not exponential. CLEAN.PeeringState.ccacting set membership —std::findonacting(replication_factor entries). O(constant). CLEAN.PrimaryLogPG.ccsnapshot clone list —std::findonsnapset.clones. In Ceph docs clones are bounded per object (defaultrbd_max_snap_count= 510, but typically far fewer). Snapshot clone lookup is called once per object read; not O(N²) across objects. CLEAN.OSDMonitor.ccpg_upmap CLI —std::findon user-supplied OSD lists for dedup; bounded by the CLI argument count. CLEAN.- CRUSH mapper (
mapper.c) — C code using integer arrays; collision avoidance uses modular arithmetic (straw2 algorithm), no linear membership scan. CLEAN.
Result: No actionable CWE-407 defects. All inner std::find calls in Ceph operate on replication-factor-sized (O(1)) vectors or small user-supplied lists; scalable paths use hash maps and sorted data structures.