replace fast_float (C++) with ffc#3329
Conversation
dvkashapov
left a comment
There was a problem hiding this comment.
The build fails currently because there is no ffc itself? Do you suggest we devendor this dependency and expect user to have it installed on the system? I just took a glance at the code, did not do a proper review.
LINK valkey-benchmark
/usr/bin/ld: cannot find ../deps/fast_float_c_interface/fast_float_strtod.o: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:727: valkey-benchmark] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/dvkashapov/ff/src'
make: *** [Makefile:6: all] Error 2
|
Hi @lemire, nice to see you here. Do you think ffc is mature enough already? I see it has a lot of activity in the last days. I hope we can avoid updating it too often. Please also add ffc.h so the code compiles. :) |
It's a fair question; all of the activity since the first release has been around project management, establishing a versioning scheme, ci, tooling on the repo itself. We have made only one true code change since release, which was not a correctness fix. The logic itself is of course very mature as it comes from fast_float and the port is direct. The question is around the accuracy of the port, but with all of the fast_float test suite passing, it seems unlikely there is any major miss. I see the existing fast_float usage is already opt-in in valkey, that could be a good way to 'let it soak' for a little while before making it the default. |
Maybe it's not necessary. Now that we have a plain C solution, and we've had fast float for a year as opt-in, it seems safe to me to use ffc now without a fallback. Let's see what others think. We made fast float opt-in just because it's C++ and we didn't want to change the toolchain requirements, but otherwise we want to avoid compile-time options. We want a uniform build and many users run on containers or other pre-built binaries and/or are not able to decide how it's compiled. |
|
Yes, I think this can be vendored. I simply forgot to check in the file, which I just did now.
Yeah. Sorry about that.
I am quite happy that valkey depends on the library that I maintain ( Maybe some background is in order. Antirez raised a bit of attention when he announced that he had used AI to port |
|
If we can review this in the next day or so, we can merge this before 9.1 cutoff. This seems worth pulling in. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #3329 +/- ##
============================================
- Coverage 75.05% 74.44% -0.62%
============================================
Files 129 130 +1
Lines 71553 72553 +1000
============================================
+ Hits 53705 54011 +306
- Misses 17848 18542 +694
🚀 New features to boost your workflow:
|
quick note - CI is failing because CMake is not updated to build/link the new |
|
@sarthakaggarwal97 Let me have a look |
|
Verified locally, I had not tested CMake. I will fix in a minute or so. |
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
zuiderkwast
left a comment
There was a problem hiding this comment.
Looks good to me. Thank you!
We wouldn't really need the fast_float_c_interface wrapper anymore. We added it for fast float to distinguish the C++ code that we built with different compiler options and linked it as a lib. With C we could just include ffc.h in e.g. src/util.c. It'd be slightly simpler, but doesn't matter much. We can also just keep it as-is.
|
@lemire Would you like to remove the extra build step and wrapper interface? I think its worth it, as the aim is toolchain complexity reduction! I could take a crack as well. |
Signed-off-by: Daniel Lemire <daniel@lemire.me>
|
I did the simplification. It does not simplify a whole lot: you basically move the definitions from the deps directory to the src directory. It is probably more or less even in terms of lines of code. BUT you do get right of an extra directory in deps, which is nice. |
zuiderkwast
left a comment
There was a problem hiding this comment.
I did the simplification. It does not simplify a whole lot: you basically move the definitions from the deps directory to the src directory. It is probably more or less even in terms of lines of code.
BUT you do get right of an extra directory in deps, which is nice.
I think it's worth it. We got rid of an extra Makefile and a CMakeLists.txt and we don't need to link it as a separate library anymore. Your last commit has good numbers:
+83 -111 lines changed
Thanks for taking the time!
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
Signed-off-by: Daniel Lemire <daniel@lemire.me>
|
@zuiderkwast I trimmed some more fat. |
- Fix release date to Mon Mar 18 2026 - Fix typos: duplicate 'load', 'keyes' -> 'keys', duplicate 'INFO' - Remove reverted contributor (arshidkv12, valkey-io#3137) - Add 7 new release-notes entries from upstream/unstable merge: CLUSTERSCAN (valkey-io#2934), MSETEX (valkey-io#3121), availability-zone (valkey-io#3156), stream range optimization (valkey-io#3002), RDB as AOF preamble (valkey-io#1901), unsigned 64-bit module config (valkey-io#1546), fast_float -> ffc (valkey-io#3329) Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
There is now a port of fast_float in C. So instead of having an optional fast_float dependency, we can just use ffc instead, unconditionally. https://github.com/kolemannix/ffc.h It is a high quality port. The performance should be the same or improved. Note : I am the maintainer and main author of fast_float. --------- Signed-off-by: Daniel Lemire <daniel@lemire.me>
There is now a port of fast_float in C. So instead of having an optional fast_float dependency, we can just use ffc instead, unconditionally.
https://github.com/kolemannix/ffc.h
It is a high quality port by @kolemannix. The performance should be the same or improved.
The PR is quite simple and should not be controversial.
Note : I am the maintainer and main author of fast_float.