1598 Commits

Author SHA1 Message Date
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
HedgehogInTheCPP
c8894d3722 Cleanup for code near merged code: compiler generate much better code in any mode without manual unroling because it's less branching and also it's allow more inlining which is better.
Merge branch 'main' of https://github.com/fastfloat/fast_float
2026-09-18 22:08:56 +03:00
HedgehogInTheCPP
016e7817be additional optimization of fraction reading for char. It's slow patch with really big numbers, so allow CPU to process it efficiently! 2026-09-16 23:27:23 +03:00
Daniel Lemire
b0ab987b3d Version 8.3.0 v8.3.0 2026-09-15 11:03:18 -04:00
Daniel Lemire
3254622f74 Add chars_format::javascript_sloppy (Annex B NonOctalDecimalIntegerLiteral)
chars_format::javascript follows the strict-mode grammar, which rejects
any leading zero. In sloppy mode, JavaScript also accepts a leading zero
when one of the digits is 8 or 9 ("08.5" is 8.5, Annex B's
NonOctalDecimalIntegerLiteral). A leading zero followed only by octal
digits is a LegacyOctalIntegerLiteral ("0775"), which is not a decimal
number: it is rejected with the new parse_error::legacy_octal_integer_part
so the caller can parse it in base 8.

javascript_sloppy sets one extra bit on top of javascript, and the check
lives inside the existing runtime JavaScript branch of
parse_number_string<false>, so the general path is unchanged. An
interleaved A/B with realbenchmark on canada.txt and mesh.txt (ASCII and
UTF-16, 32/64-bit) shows identical instructions per float and cycles
within noise.

Document both formats in the README.
2026-09-15 10:52:49 -04:00
Daniel Lemire
e0e355c073
Merge pull request #407 from fastfloat/javascript-format
Add chars_format::javascript (ECMAScript DecimalLiteral)
2026-09-15 10:44:07 -04:00
jadidbourbaki
20a9b35333 Gate the subnormal tie test on a compile-time predicate 2026-09-15 09:11:27 -04:00
jadidbourbaki
abb4c8659a Fix std::float16_t rounding of subnormal ties and fast-path overflow 2026-09-14 22:15:45 -04:00
Daniel Lemire
4fcb7e3249 Fix clang-format 17 on FASTFLOAT_ASSERT macros 2026-09-14 20:46:52 -04:00
Daniel Lemire
f837a78057 Add chars_format::javascript (ECMAScript DecimalLiteral)
The JSON format rejects leading zeros, which JavaScript also rejects,
but it further requires digits on both sides of the decimal point,
which JavaScript does not: ".5", "5." and "5.e3" are all valid
DecimalLiteral productions. Users lexing JavaScript therefore could not
use chars_format::json and had to re-check the integer span themselves
after a general-mode parse.

chars_format::javascript is general mode plus the leading-zero rule
(reported as leading_zeros_in_integer_part), with no_infnan. It is a
runtime check on the format, like fortran, so it reuses the existing
parse_number_string<false> instantiation. A leading minus sign is
accepted, and a leading plus sign with allow_leading_plus.

Claude-Session: https://claude.ai/code/session_01KbAWRBpE3MPy5cXECc5vWZ
2026-09-14 19:36:49 -04:00
HedgehogInTheCPP
fa8c3a711a lint 2026-09-04 04:20:34 +03:00
HedgehogInTheCPP
52aef56385
Remove Codecov badge from README
Removed Codecov badge from README.md.
2026-09-04 03:09:23 +03:00
HedgehogInTheCPP
15ab8caa1f reduce data cache pressure. 2026-09-04 03:08:31 +03:00
HedgehogInTheCPP
42abbcbb34 lint unfck. 2026-08-29 17:52:00 +03:00
HedgehogInTheCPP
9b3d9f7b1a add fastfloat_noinline from https://github.com/fastfloat/fast_float/pull/403 my fork don't need any additional from this PR because it's already simd optimized more strictly. 2026-08-29 17:33:00 +03:00
HedgehogInTheCPP
c1b6fa94ad Upgrade sanitize and amalgamate workflow to the Ubuntu latest, it's better! 2026-08-26 01:44:40 +03:00
HedgehogInTheCPP
428c9bff9c Only disable assume for GCC. 2026-08-26 01:36:23 +03:00