1615 Commits

Author SHA1 Message Date
HedgehogInTheCPP
448e6c8fd9 reduce data cache pressure. 2026-10-10 18:37:15 +03:00
HedgehogInTheCPP
ad630d9c2e Merge branch 'main' of https://github.com/fastfloat/fast_float 2026-10-10 01:54:56 +03:00
github-actions[bot]
42f254836e Version 8.3.2 v8.3.2 2026-10-09 19:56:38 +00:00
Daniel Lemire
91aef729bd
Merge pull request #422 from sahvx655-wq/is-integer-signed-overflow
avoid signed overflow in is_integer on negative wchar_t units
2026-10-09 15:54:46 -04:00
Sahana Bogar
50f01dbb51 avoid signed overflow in is_integer for negative code units 2026-10-08 19:12:13 +05:30
Daniel Lemire
54571f86e3
Merge pull request #421 from sahvx655-wq/times-pow10-int64-min
avoid signed negation overflow in integer_times_pow10
2026-10-06 19:48:48 -04:00
Sahana Bogar
1271675129 avoid signed negation overflow in integer_times_pow10
Negating the most negative int64_t is undefined behaviour. GCC at -O2 uses that to turn the fast-path mantissa bound into a signed compare and returns the wrong sign, so take the magnitude in uint64_t instead.
2026-10-05 22:46:40 +05:30
github-actions[bot]
f3f02c8ad0 Version 8.3.1 v8.3.1 2026-10-04 16:26:53 +00:00
Daniel Lemire
963467e89d
Merge pull request #420 from fastfloat/release-workflow
Add manually triggered release workflow; fix on-release asset upload
2026-10-04 12:24:46 -04:00
Daniel Lemire
e62540e95f Add manually triggered release workflow; fix on-release asset upload
- New release.yml (workflow_dispatch): bumps patch/minor/major, runs
  script/release.py, tests the amalgamation and the full test suite,
  commits and tags on main, and publishes a release with fast_float.h.
- on-release.yml: the upload failed with 'Validation Failed' because
  fast_float.h was already attached to the release. Use
  'gh release upload --clobber' instead of the deprecated
  actions/upload-release-asset, and run the amalgamation test binary.
- release.py: also bump MODULE.bazel (stuck at 8.2.4) and exit non-zero
  if amalgamation fails.
2026-10-04 12:05:40 -04:00
Daniel Lemire
3e4f80fcc4
Merge pull request #419 from fastfloat/fix-418-struct-layout
Reorder parsed_number_string_t fields to avoid padding (fixes #418)
2026-10-04 11:59:23 -04:00
Daniel Lemire
fe5e97eeac Reorder parsed_number_string_t fields to avoid padding (fixes #418)
Placing the parse_error field next to the booleans shrinks the struct
from 72 to 64 bytes on 64-bit systems, recovering a large performance
regression observed with MSVC. Add a static_assert to guard the size.
2026-10-04 09:34:39 -04:00
Daniel Lemire
9498cc361e
Merge pull request #417 from fastfloat/fix-alpine-ci
CI: pin Alpine to v3.22 to fix setup-alpine failures
2026-09-26 15:30:01 -04:00
Daniel Lemire
c31e0294c3 CI: pin Alpine to v3.22 (setup-alpine v1 fails with apk-tools v3) 2026-09-26 14:53:33 -04:00
HedgehogInTheCPP
3bf6360bfa Merge branch 'main' of https://github.com/fastfloat/fast_float 2026-09-26 19:18:33 +03:00
Daniel Lemire
1dc46a6b8f
Merge pull request #409 from caolanm/main
drop the unreachable tail of parse_mantissa
2026-09-25 18:21:25 -04:00
HedgehogInTheCPP
1e10ad47c7 Merge branch 'main' of https://github.com/fastfloat/fast_float 2026-09-24 00:51:31 +03:00
HedgehogInTheCPP
5f8293324b cleanup. 2026-09-24 00:41:45 +03:00
Daniel Lemire
f103228650
Merge pull request #415 from Algunenano/fix-benchmark-branch-misses
Average branch misses over the repetitions in the benchmark
2026-09-23 14:12:38 -04:00
Raúl Marín
38168208f6 Average branch misses over the repetitions in the benchmark
bm/f printed the total over all repetitions per float, unlike the other counters.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 19:12:41 +02:00
HedgehogInTheCPP
b5a2f54e30 Readme update. 2026-09-23 03:54:18 +03:00
HedgehogInTheCPP
2f67e94234 Merge branch 'main' of https://github.com/IRainman/fast_float 2026-09-23 03:36:02 +03:00
HedgehogInTheCPP
385b22592f compilation fix. 2026-09-23 03:35:55 +03:00
HedgehogInTheCPP
d3e3a2f5d2
Merge pull request #26 from IRainman/main-cf-autofix
Apply fixes from CodeFactor
2026-09-23 03:28:30 +03:00
codefactor-io
59bd494918
[CodeFactor] Apply fixes 2026-09-23 00:25:33 +00:00
HedgehogInTheCPP
d2934c2f46 compilation fix. 2026-09-23 03:22:44 +03:00
HedgehogInTheCPP
4aae299916 compilation fix. 2026-09-23 03:09:06 +03:00
HedgehogInTheCPP
42cd121f12 compilation fix. 2026-09-23 03:00:41 +03:00
HedgehogInTheCPP
f89bb255b6 lint unfck. 2026-09-23 02:53:12 +03:00
HedgehogInTheCPP
ac96536399 Cleanup for code related with merge and add some documentation.
Merge branch 'main' of https://github.com/fastfloat/fast_float
2026-09-23 02:51:34 +03:00
Daniel Lemire
cdc385d058
Merge pull request #408 from jadidbourbaki/float16-exactness
Fix std::float16_t rounding of subnormal ties and fast-path overflow
2026-09-22 14:11:44 -04:00
Daniel Lemire
82623d83c5 Avoid right-shifting a negative value in subnormal_ties_possible() 2026-09-22 13:57:31 -04:00
Daniel Lemire
7969d5089c
Merge pull request #413 from fastfloat/clang-format-fold
Fold the format at compile time under clang, mark cold checks unlikely
2026-09-21 22:51:08 -04:00
Daniel Lemire
b57a12270e Fold the format at compile time under clang, mark cold checks unlikely
Clang generated ~35% more instructions per float than GCC on identical
code (canada.txt, 64-bit: 276 vs 200 i/f on a Xeon Gold 6548N). Two
causes, confirmed with exact instruction traces:

1. Clang declines to inline the parser (from_chars_caller<T>::call) into
   its callers, so parse_options stays a runtime value and every format
   flag is re-tested on every conversion: javascript, skip_white_space,
   allow_leading_plus, fixed/scientific, the decimal point, the JSON
   dispatch. GCC inlines the whole parser into each call site, where
   chars_format::general is a constant, and all of it folds away.

   Fix: from_chars dispatches chars_format::general to a
   from_chars_fixed_format<T, UC, Fmt> instantiation, so the format is a
   compile-time constant inside the parser body whether or not the user's
   call is inlined. The call forwarder gets fastfloat_clang_really_inline
   so that it folds into that instantiation.

2. Clang if-converts the rare over/underflow fix-ups at the end of
   compute_float and the result_out_of_range test into cmov chains that
   every conversion executes. Marking them fastfloat_clang_unlikely keeps
   them as never-taken branches.

Both are applied under clang only, and GCC's generated code is identical
to before (verified on the object code). That is on purpose: forcing
always_inline on from_chars, or even on the trivial call forwarder,
regressed GCC by up to 14% on mesh.txt by changing its inlining order;
dispatching to the fixed-format instantiation made it stop inlining into
the loop; and the unlikely hints alone cost it 2-6% on mesh.txt by
reordering blocks (GCC already emits branches there).

realbenchmark, cycles per float, 5 interleaved rounds, medians:

clang 21, Xeon Gold 6548N        before   after
  canada.txt ASCII  (64)          49.7    44.6   -10%
  canada.txt UTF-16 (64)          57.4    52.0    -9%
  mesh.txt   ASCII  (64)          26.5    22.4   -16%
  mesh.txt   UTF-16 (64)          28.1    24.0   -15%
  (32-bit: -8% to -14%)
gcc 14, same machine: generated code unchanged.
Apple clang 17, arm64: +3% to +18% Mfloat/s.
2026-09-21 22:30:43 -04:00
Daniel Lemire
e9e04dec19
Merge pull request #412 from fastfloat/strncasecmp-simple
Restore the simple loop in fastfloat_strncasecmp
2026-09-21 22:17:08 -04:00
Daniel Lemire
7e45de0c3b Restore the simple loop in fastfloat_strncasecmp
PR #356 replaced the 3/5-character case-insensitive compare used by
parse_infnan with SWAR helpers (fastfloat_strncasecmp3/5 plus a generic
memcpy-based fastfloat_strncasecmp). That code only runs for "nan",
"inf" and "infinity" inputs, so it cannot help ordinary parsing, but it
grew the inlined inf/nan tail of the parser: on x86-64 (GCC 14 and
clang 21) the per-commit benchmarks dropped by 1.5-2.5% because the
extra dead code changed inlining decisions and register allocation on
the hot path (+7 instructions/float on canada.txt).

Go back to the plain loop, which the compiler unrolls for the constant
lengths 3 and 5, and drop the now-unused generic SWAR function. The
`actual < 256` guard of the original is unnecessary: OR-ing 0x20 into
a value can only equal an ASCII lowercase letter when the value is that
letter or its uppercase form, so the plain OR is exact for every
character type.
2026-09-21 22:05:34 -04:00
Daniel Lemire
6373592899
Merge pull request #410 from Algunenano/javascript-fmt-hot-path
Keep chars_format::javascript out of the common hot path
2026-09-21 19:01:45 -04:00
Raúl Marín
b2e41e8b88 Keep chars_format::javascript out of the common hot path
8.3.0 added the ECMAScript leading-zero rule as a runtime test on fmt inside
parse_number_string, so unlike basic_json_fmt its error returns and Annex B
octal scan land in the parser body that every from_chars instantiation
force-inlines. from_chars_caller<double>::call grew from 935 to 1031
instructions and other formats lost about 3% on short inputs.

Make the rule a compile-time parameter of the parser body, selected once at the
entry point, and take chars_format::javascript out to a cold conversion before
anything else is live so the branch is a tail call. parse_number_string keeps
its signature and behaviour.

benchmarks/benchmark.cpp, Intel Xeon 6975P-C, clang 22.1.8, cycles per float,
best of 7:

              canada.txt    mesh.txt
  8.2.10         47.03        24.78
  8.3.0          47.34        26.08
  this           46.28        24.86
2026-09-21 19:47:21 +00:00
HedgehogInTheCPP
bfd1af3905
Update include directive from fmt/base.h to fmt/core.h 2026-09-20 02:06:15 +03:00
HedgehogInTheCPP
d727092daf
Update performance link in README
Updated the result description with a new link for performance improvements.
2026-09-19 23:50:24 +03:00
HedgehogInTheCPP
edd182f509 workflow cleanup with permissions: contents: read. 2026-09-19 23:38:54 +03:00
HedgehogInTheCPP
7ad87515ad I'm not sure why plus here should be ignored. But OK. Biodegradable test code:
auto answer = fast_float::parse_number_string<true>(
        f.data(), f.data() + f.size(),
        fast_float::parse_options(
            fast_float::chars_format::json |
            fast_float::chars_format::allow_leading_plus)); // should be ignored
    if (!answer.invalid) {
      std::cerr << "json parse accepted invalid json " << f << std::endl;
      return EXIT_FAILURE;
    }
2026-09-19 23:14:01 +03:00
HedgehogInTheCPP
d577161969 additional cleanup, more unlikely and likely. Fix JSON related errors. Speedup JSON parsing if errors. 2026-09-19 23:01:11 +03:00
HedgehogInTheCPP
d633ecb297 Fix JSON parsing error.
Remove FASTFLOAT_CONSTEXPR17 from json_fmt because it's a template parameter.
2026-09-19 21:11:26 +03:00
HedgehogInTheCPP
5f6c3c8df9 More optimized code especially if FASTFLOAT_ISNOT_CHECKED_BOUNDS or FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN defined.
Cleanup in many parsing parts.
Fix an error in JSON parsing.
2026-09-19 20:29:11 +03:00
HedgehogInTheCPP
a4d1a08732 tests 2026-09-19 00:58:34 +03:00
HedgehogInTheCPP
b8392a5ada unfck 2026-09-19 00:37:11 +03:00
HedgehogInTheCPP
8c8d69ecc1 unfck. 2026-09-18 23:58:50 +03:00
HedgehogInTheCPP
71b0109af3 tests unfck. 2026-09-18 22:37:36 +03:00
HedgehogInTheCPP
af9f2b8dc2 unfck 2026-09-18 22:25:08 +03:00