RUG, investigated.
Three focused contributions.

A C++98 parser generator.
Three contributions, with evidence.

THE PROJECT / RUG

ABNF in.
A byte parser out.

RUG — Rug Understands Grammar — compiles ABNF into packed LALR(1) tables. Its immutable runtime image can be shared by incremental parsing sessions, with semantic callbacks and explicit workspace control.

Upstream
roman-starcevic/RUG
C++98 · Apache-2.0
Audit baseline
fe40fab82c61a6fdd95fa49162a289e703644f1c
All performance candidates were measured against this unmodified revision.
Review status
3 PRs submitted · 0 merged in this snapshot

THE INITIAL AUDIT

Build, parse,
test the boundaries.

Portability and robustness were established before proposing changes. These checks describe the baseline audit, not a new four-distro campaign for the optimized code.

01 / DISTROPROOF

Four distributions, two compilers.

Debian 12, Ubuntu 24.04, Fedora 44 and Alpine 3.24 passed builds and calculator/ticket examples with GCC and Clang, in disposable VMs using their own kernels.

02 / SANITIZERS & FUZZING

Exercise invalid and incremental input.

Ten host build configurations and 60 deterministic ASan/UBSan workload checks passed. Bounded grammar and runtime fuzz campaigns completed 44,476 and 48,605 executions without a confirmed sanitizer finding. This is not proof of safety.

THE UPSTREAM CONTRIBUTIONS

One fix.
Two independent optimizations.

Each PR contains its own change and tests. The performance PRs also include measured pairs and standalone reproduction scripts.

ContributionWhat changedPRStatus
Structured grammar diagnosticsReject empty/comment-only grammars through RugBuildError instead of leaking logic_error past callers catching the documented type.#1 Open
Packed table lookupsResolve immutable ACTION/GOTO/rule section addresses once per lookup, avoiding repeated out-of-line accessor calls.#2 Open
Default-action frequency countsReplace quadratic recounting of 257 actions with frequency counts and an ordered selection pass, preserving ties.#3 Open

Status snapshot: 2026-10-23 UTC. Follow each PR for current discussion; submitted does not mean accepted.

THE MEASURED RESULTS

Less work in the parser.
Less work building it.

Two separate before/after experiments on the same machine and compiler. Their gains must not be multiplied or presented as a combined result.

PARSING / 18 SHAPES

20.6–37.0 %

Lower parse/reset time

Across six workloads and three chunk sizes. Ten paired trials per case, following warmup.

Method and raw pairs

GRAMMAR CONSTRUCTION / 6 INPUTS

15.9–31.1×

Faster warm construction

Full repeated Rug build/destruction. Complete runtime images matched byte for byte for the six grammars.

Method and raw pairs

Ryzen 9 3900X · GCC 16.2.1 · C++98 · -O2 -g -fno-omit-frame-pointer · no LTO. These are workload-specific observations, not universal speedups or results merged upstream.

A CLOSER LOOK

The same workloads.
A repeatable comparison.

Parsing below uses 4096-byte chunks; the report includes all three chunk sizes. Construction values are per full build. Ratios use paired medians.

WorkloadParsing time reductionBaseline buildOptimized buildBuild speedup
tiny23.6 %0.944 ms0.033 ms28.53×
medium25.9 %15.726 ms0.506 ms31.05×
large25.9 %61.787 ms2.242 ms27.57×
binary21.1 %61.323 ms2.535 ms24.13×
calculator37.0 %21.855 ms1.372 ms15.87×
ticket33.0 %31.989 ms1.390 ms22.92×

The parsing and construction columns describe different isolated code changes, not a single combined binary.

THE TOOLS / WHAT THEY ACTUALLY DID

Observe the cost.
Validate the hypothesis.

The approach follows workload characterization, a partial USE screen, CPU profiling and controlled experiments, inspired by Brendan Gregg’s public methods.

01 / OMNISCIENT

Profiles first, counters after.

A local omn 0.1.0 build identified lookup/accessor costs and table-construction hotspots. Five paired PMU runs observed 26.5% fewer retired instructions for parsing and 96.8% for construction on fixed workloads. Analysis of the source led to the patches; the tool did not optimize code automatically.

02 / OTHER TOOLS & BOUNDARIES

Keep each tool’s role explicit.

distroproof supplied the baseline VM matrix. ATFQ supplied memory context, xpac read package inventory; neither was a RUG profiler. VMAnyware was not used. Omniscient’s full BPF-backed USE/latency modes refused missing permissions; available user-space CPU sources were used instead.

VALIDATION & LIMITS

The evidence has a scope.
So do these results.

Both candidates passed fresh GCC and Clang ASan/UBSan builds, independent oracles, examples and differential incremental traces. The optimizations were not re-tested on the four-distro matrix, with LTO or on other hardware.

Correctness checks
4,626 ACTION/GOTO results per lookup oracle; 300 default-action rows including ties; byte-identical images for six grammars; callbacks, error spans and reset/reuse checks.
Measurement limits
Targets were pinned to one CPU, but frequency and thermals were not locked. Final PMU counts were user-only and not multiplexed. Profiling reported no loss; collector overhead excludes part of its in-target cost.
Tradeoffs
The construction histogram adds temporary map allocations, bounded by 257 distinct keys per row. No memory reduction, security assurance or maintainer endorsement is claimed.

REPORTS & REPRODUCTION

Read the analysis.
Reproduce the measurements.

Download the report, inspect the data, or follow the independent reproduction instructions in each performance PR.

Independent contribution by moha-bekh. PR status is the dated snapshot above; no RUG maintainer endorsement is implied.