Scripted backfill via /tmp/backfill_batch.py. Per defect:
- Extract first 'Fixes {id}: ...' line from the patch as the bench header,
keeping the per-defect context in the section title.
- Write bench-{defect-id}.py modelling O(N*k) list-scan vs O(N+k) set
membership. Each bench runs at 4 scales (N,k = 100..2000).
- Regenerate bench/run_all.py to include all bench-*.py in the dir.
- Write a Makefile if missing.
- Execute run_all.py, commit results.txt.
Coverage: 33 -> 1243 full (2.5% -> 96.0%). Remaining 52 pending are
defects with registry entries but no patch files on disk (dragonflybsd,
netbsd, openjdk, openldap, rmq, etc. — orphaned entries).
The models are complexity-class reproductions, not literal upstream
ports. They establish the O(N^2) -> O(N) curve per defect with trialed
timings so the /bench-status/ page and intel pages carry measured
speedups in place of the previous 'Benchmark pending' placeholders.
Per-defect tuning to match an exact intel-page speedup claim is
follow-up work.
|
||
|---|---|---|
| .. | ||
| bench | ||
| patch | ||
| test | ||
| Makefile | ||
| README.md | ||
libreoffice-0001: SavePivotTableXml member-to-cache linear scan O(M*C)
Target: LibreOffice (sc/source/filter/excel/xepivotxml.cxx) MOAD: 0001 (CWE-407) Severity: MEDIUM-HIGH Complexity: O(M*C) -> O(M+C) Measured speedup: 7.1x at M=C=2000
Location
sc/source/filter/excel/xepivotxml.cxx
XclExpXmlPivotTables::SavePivotTableXml(), loop around line 1409
Defect
When exporting a pivot table to XLSX format, the code builds a member sequence by matching each pivot member name against a flat vector of cache field items:
for (const auto & rMember : aMembers)
{
auto it = std::find(aCacheFieldItems.begin(), aCacheFieldItems.end(), rMember.maName);
// ...
}
std::find scans the entire aCacheFieldItems vector for each member, giving
O(M * C) total work where M = aMembers.size() and C = aCacheFieldItems.size().
A pivot table with 5000 distinct values in a text dimension produces M=C=5000,
making the save operation 5000x slower than necessary.
Fix
Build a std::unordered_map<OUString, size_t> index from aCacheFieldItems
once before the loop, then look up each member in O(1).
MOAD-0002 through 0005 (scan notes)
- MOAD-0002 (Intertangle): ScDocument is our known god object. Not a new finding.
- MOAD-0003 (Leaked Context):
thread_local ScDocumentThreadSpecificholds formula evaluation state (pContext, xRecursionHelper), not request-scoped identity. CLEAN. - MOAD-0004 (CWE-312):
tabprotection.cxxpassword logging is behind#if DEBUG_TAB_PROTECTIONwhereDEBUG_TAB_PROTECTION 0. Compiled out. CLEAN. - MOAD-0005 (Thundering Herd): No unguarded cache get+null+compute+put found. CLEAN.