Skip to content

Simplify the options cache, the benchmark doc and the CI - #13

Merged
pscheid92 merged 1 commit into
mainfrom
simplify
Nov 10, 2026
Merged

pscheid92 merged 1 commit into
mainfrom
simplify

Conversation

@pscheid92

Copy link
Copy Markdown
Owner

Takes back the parts of the last pull request that were more than the library needs, and removes tooling that was
there for show. 13 files, 832 lines removed, 179 added.

The options cache

The options of each format are built once at start-up and shared. A call with AlsoAccept or AcceptDays builds
new ones. Before, a table of 768 atomic pointers, indexed by a bit set of formats, made every combination free.

Before After
With(ISO8601) 5 ns, 0 allocations 9 ns, 0 allocations
With(ISO8601, AlsoAccept(Nano)) 8 ns, 0 allocations 301 ns, 14 allocations
Reading with those options built on every call 231 ns, 0 allocations 678 ns, 19 allocations
Reading with those options kept in a variable 225 ns 223 ns

So the documentation now says to keep options that have decoding options in a variable, which every example already
did. No release contains the earlier promise.

Gone with the table: the bit set, the numbers of the formats and their test, the option that had to be one byte, and
the tests of first calls and of stored values. What stays the same: the order of the formats in AlsoAccept makes no
difference, error messages name the written format first, and an invalid format panics in AlsoAccept.

Benchmarks

  • BENCHMARKS.md goes from 212 lines to 42: what tests enforce, one table marked as a single measurement, and how to
    measure. The README quotes no nanoseconds.
  • bench_test.go keeps the benchmarks the doc relies on, 307 lines instead of 547.
  • The test that pinned exact allocation counts of errors is removed. It had failed on Linux, where the standard
    library allocates differently.

CI and badges

  • One fuzz job runs just fuzz and just compat-fuzz in place of a job that listed the targets and a matrix of
    seven. It keeps the cache of found inputs and the upload of a failing input. The targets now run one after the
    other: about five minutes on a push, about 70 at night.
  • The coverage badge job is removed. CI already fails below 100%, so the badge could only say 100%.
  • The Scorecard workflow is removed. The README keeps the CI and Go Reference badges. SECURITY.md and CodeQL stay.

None of the removed jobs is a required check.

Reasons in the docs

  • A Format is a name, so that a flag or a configuration can hold one, and an invalid one is a programming error,
    like time.Month(13).
  • Exponents are rejected on purpose.
  • A sign inside an ISO 8601 duration, as in Java's PT-30S, is rejected as the format tag of encoding/json/v2
    did. Checked against that code: it rejects PT-30S and P-1D and reads a leading sign.

No behaviour of decoding or encoding changes.

Checks

  • just check passes, with 100% statement coverage. go vet passes for linux/386.
  • just mutate: no change survives. The last run had 11 timeouts on a loaded machine; two of them, applied by hand,
    fail the tests within two seconds.
  • The new fuzz job has only run through actionlint and the recipes locally. This pull request is its first run.

After the merge, the badges branch is unused and can be deleted.

The options of each format are built once at start-up and shared. A call with AlsoAccept or AcceptDays builds new
ones, so the documentation says to keep those in a variable. This replaces a table of 768 atomic pointers that made
every combination of options free, with the bit set, the format numbers and the tests that served it.

BENCHMARKS.md keeps what tests enforce and one table marked as a snapshot, and the README quotes no nanoseconds.
The benchmarks are cut to the ones the doc relies on, and the test that pinned exact allocation counts of errors is
gone.

CI fuzzes in one job instead of a generated matrix. The coverage badge job and the Scorecard workflow are removed,
and the README keeps the CI and Go Reference badges.

The README and the documentation of Format now give the reasons for three choices: a Format is a name and an
invalid one a programming error, exponents are rejected on purpose, and a sign inside an ISO 8601 duration is
rejected as the format tag of encoding/json/v2 did.
@pscheid92
pscheid92 merged commit 90a3384 into main Nov 10, 2026
11 checks passed
@pscheid92
pscheid92 deleted the simplify branch November 10, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant