Skip to content

Add Eisel-Lemire decimal parsing fast path - #3957

Draft
Yu-zh wants to merge 2 commits into
mainfrom
perf/eisel-lemire
Draft

Add Eisel-Lemire decimal parsing fast path#3957
Yu-zh wants to merge 2 commits into
mainfrom
perf/eisel-lemire

Conversation

@Yu-zh

@Yu-zh Yu-zh commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a correctly rounded Eisel-Lemire fast path to internal/strconv
  • pass JSON scanner mantissa/exponent data directly to the fast path
  • retain the existing Clinger path and exact Decimal fallback for ambiguous, truncated, subnormal, and out-of-range inputs
  • add differential correctness tests, Canada-style coordinate cases, and parsing/JSON benchmarks
  • record the Go 1.26.2 source adaptation in NOTICE

Motivation

Canada coordinate values such as -65.613616999999977 have 17-19 digit mantissas that exceed the exact Clinger limit. Nearly every coordinate therefore fell back to arbitrary-precision Decimal conversion, making decimal parsing the dominant JSON decode cost.

The new path handles those mantissas with cached powers and explicit ambiguity checks. Inputs that cannot be certified by the fast path continue through the existing exact conversion.

Performance

Benchmark Before After Improvement
parse_double, long mantissas (4,096 parses) 879.50 us 245.99 us 3.58x
JSON long-mantissa array (10,000 numbers) 2.88 ms 1.05 ms 2.74x

Existing integer and short-float paths remained within benchmark noise.

Validation

  • moon test internal/strconv json --target all: 228/228 passed on native, JS, Wasm, and Wasm-GC
  • full native suite: 6,835/6,835 passed
  • full JS suite: 6,878/6,878 passed
  • full Wasm-GC suite: 6,926/6,926 passed
  • moon check --target all --warn-list +73
  • moon info and moon fmt
  • git diff --check
  • no generated .mbti changes

A full moon test --target all run reached an unrelated host-environment failure in the builtin Wasm tests because wasi_snapshot_preview1.random_get was not callable. The affected internal/strconv and json packages pass independently on Wasm.

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