apple/swift-asn1: 10.98× faster PEM parsing, on a local clone
CAVEATED
nothing contributed upstream · 13 unsafe sites not reviewed
HEADLINE
10.98× faster
PEM parsing · the product of the per-experiment ratios
before → after
bar length is relative to the before valuePEM parsing, cumulative−90.9%
what changed
PEMDocument.swift was idiomatic Swift over Substring.UTF8View. The profile put firstIndex(of:) at 63% of the time and base64 decoding at 6%. The run moved the same algorithm onto raw bytes. The win is raw pointer arithmetic, which the harness flagged at 13 unsafe sites.
11 experiments
9
kept
2
discarded
0
failed
note — 9 of 11 is not the expected hit rate. The first two experiments recovered 4.7×, and experiments 10 and 11 moved the benchmark by 0.06% and 0.08%. All 118 of the library’s own tests pass, but frozen tests cannot catch undefined behaviour. This change needs a human review and a fuzz run over malformed PEM.
how it was measured
- tool
ordo-one/package-benchmark- rounds
- 10 interleaved rounds per side
- verdict rule
- alpha 0.005. A KEEP needs a win of at least 3%. A significant regression past 3% is refused.
LIMITS
Results hold only for the benchmarks a run measures. Inputs they do not cover can get slower. Check your hot paths before you merge.