Skip to content

Commit 6c59129

Browse files
dfa1claude
andcommitted
build(sonar): exclude generated fbs/proto from analysis; document dup trade-off
Generated FlatBuffers/Protobuf sources were excluded from coverage only, so their machine-style naming and copy-shaped accessors still contributed ~160 code smells and padded the duplication metric. Add sonar.exclusions to drop them from analysis entirely. ADR 0005 gains a Consequences note: per-width/per-ptype loop duplication (unpackLoop16/32/64 etc.) is a deliberate cost of keeping hot-loop bodies uniform for C2 auto-vectorization, not a defect to refactor away. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 840cc46 commit 6c59129

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/adr/0005-vector-api-adoption.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ loop structure.
120120
- If Vector API finalizes and shows large gains, this deferral costs
121121
time. Mitigation: the TODO items remain; the ADR is the trigger to
122122
act when conditions are met, not a permanent block.
123+
- **Code duplication is a deliberate cost of the auto-vectorization
124+
strategy.** Keeping each hot loop's body uniform (condition for C2
125+
superword) forces *monomorphization* — one specialized copy per element
126+
width / ptype rather than a shared generic loop. `BitpackedEncodingDecoder`
127+
carries `unpackLoop16` / `unpackLoop32` / `unpackLoop64`, three ~96-line
128+
methods identical except for their `2L`/`4L`/`8L` strides and
129+
`LE_SHORT`/`LE_INT`/`LE_LONG` accessors (~254 duplicated lines, ~48%
130+
of the file). They cannot be merged: a single generic loop parameterized
131+
by element width reintroduces a per-element variable-width branch, which
132+
is exactly what makes C2 refuse to vectorize. The same trade-off produces
133+
the per-ptype duplication in `DeltaEncodingEncoder`, `AlpEncodingEncoder`,
134+
and the FrameOfReference paths.
135+
136+
Consequence for tooling: SonarCloud reports this as duplication
137+
(project density ~4.7%, dominated by these files). That number is
138+
expected and should not be "fixed" by collapsing the loops — doing so
139+
would regress throughput. If the metric becomes noisy, suppress it for
140+
the specialized decoders via `sonar.cpd.exclusions` rather than
141+
refactoring. (Generated `fbs/`/`proto/` sources are already excluded
142+
from analysis via `sonar.exclusions` for the same reason — machine
143+
output, not hand-maintained code.)
123144

124145
### Risk
125146
- If a downstream consumer benchmarks the library and finds a

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@
8686
**/proto/**,
8787
**/performance/**
8888
</sonar.coverage.exclusions>
89+
<!-- Generated FlatBuffers/Protobuf sources under fbs/ and proto/ are emitted
90+
verbatim by external code-gen and never hand-edited. Their machine style
91+
(getRootAsX naming, redundant casts) trips ~160 smells and pads the
92+
duplication metric with copy-shaped accessors, all unactionable noise.
93+
Exclude from analysis entirely, not just coverage. -->
94+
<sonar.exclusions>
95+
**/fbs/**,
96+
**/proto/**
97+
</sonar.exclusions>
8998
<!-- Coverage sources:
9099
1. per-module surefire (unit tests)
91100
2. per-module failsafe (module-local integration tests)

0 commit comments

Comments
 (0)