-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including FastFloat in parsing process #62301
Including FastFloat in parsing process #62301
Conversation
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsThis PR is a contribution to runtime regarding issue ##48646 to insert Lemire's Fast-float algorithm to doube/single/half parsing process. Steps in the draft will be :
@EgorBo @tannergooding @lemire
|
Awesome!
|
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
yes, it looks like something' trying to read above 19 digits... |
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
…oFloatingPointBits.cs Co-authored-by: Günther Foidl <[email protected]>
…oFloatingPointBits.cs Co-authored-by: Günther Foidl <[email protected]>
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
A lot of the original code has been transformed to look like heap allocations ( https://github.com/CarlVerret/csFastFloat/blob/master/csFastFloat/Constants/Constants.cs I am no C# expert but representing constant arrays as heap-allocated content seems likely to trigger heap allocations during the execution of the code which will surely harm the performance. Of course, maybe this gets optimized away. But are we sure it is the case? |
@lemire is correct and these should stay as |
Reading the comments, I understand that @EgorBo suggested writing the code for the upcoming language support. Of course, this might imply that the current draft PR should be expected to have suboptimal performance with the current language support. |
…Verret/runtime into 48646-FastFloat-integration
This reverts commit 1b5fd51.
I ran existing benchmarks on both double and float : comparing main branch with this PR
|
I agree with @tannergooding and @lemire that we should stick with static readonly array fields until compiler support is actually in place. At that point, there are many other places we'll be updating, and we can just update these as part of that. |
src/libraries/System.Private.CoreLib/src/System/Number.NumberToFloatingPointBits.cs
Outdated
Show resolved
Hide resolved
Thank you Tanner. It has been a nice learning occasion for me. |
Thank you as well, excited to get this in once CI is passing (the OSX failure was unrelated; I've not looked at the other 2 yet). |
is there something I can do to help with failing checks ? |
We need to ensure they aren't related and ideally get CI passing. It looks like there is an arm32 timeout that should have been resolved in #63357 If you push a merge commit integrating the current I'm decently confident that the remaining failures are not related to your changes here and are instead CI issues on our side, so I can also take care of pushing the relevant merge commit if you would prefer |
Simply clicking close then reopen will restart validation on rebased code of course. Assuming no conflicts. |
@tannergooding historically you ran I think an extra JavaScript test corpus - is that necessary too? |
@danmoseley, those run implicitly now: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime/tests/System/DoubleTests.cs#L378-L419 There are always more test suites we could run on top, but I wouldn't expect they would catch anything additional here.
I've seen issues with that in the past and have found pushing a merge commit to be much more reliable. |
just to make sure I'm doing the right thing here : you mean pulling the main into my branch then push back my branch to update this PR? |
Right, something roughly equivalent to:
Where |
OSX failures are #65000. Going to merge this, thanks a lot for the contribution @CarlVerret (and @lemire for the original algorithm/base implementation)! |
@tannergooding maybe just a little question regarding this PR. Will this contribution be available only for a future version (7.x) of the .net core framework or it will be also included for previous versions ? (5.x, 6.x, etc...) Is there an ETA for a public release of the runtime including this PR ? |
Only on future versions of .NET (7.x and later), we don't tend to backport perf improvements to past releases (even LTS) due to the risk. This should be available in nightly runtime builds as soon as later today (https://github.com/dotnet/runtime/blob/main/docs/project/dogfooding.md has some more info on how to try out nightly builds) and in the nightly SDK likely in a few days (same link has info on this as well). It should ship publicly in .NET 7 Preview 2 |
Fine, thanks! I was asking because csFastFloat was built upon .net core 5 and I'd like to run my benchmarks again to compare with 7.x. The goal is to evaluate the impact of another contribution we might suggest for the parsing process. |
I probably missed it, but do the inputs to our existing benchmarks in dotnet/performance suffice here? Or should we extend with some of the inputs that proved this change? (your point taken about functional tests) |
There are lots of improvements we could potentially make to the perf tests, but the current should be at least somewhat representative. I'd be more interested in what things like ML.NET show with this change. |
Nice improvements: dotnet/perf-autofiling-issues#3531 and dotnet/perf-autofiling-issues#3543 cc @CarlVerret |
Noting that the improvement is for long strings and is going from 300ns to 100ns while the regression is for a short string and is going from 35ns to 37ns. This regression is acceptable, but we should do some minimal investigation to see what is slower here (its probably just a branch or some other minor thing and if its trivially "fixable", then we should do so; but its not worth spending a lot of time on it). |
While programming the PR, i've tried to identify what could cause this little regression without any luck. I am really interested if you can provide some insight on how to fix that kind of variation. |
I'll run this through AMD uProf (https://developer.amd.com/amd-uprof/) and see if I can see anything interesting. |
This PR adds a new fast path to the processing of the floating-point numbers. It is used when the existing fast path (Clinger's) fails to apply, but before the existing 'slow path' is used. There's a corresponding issue ##48646.
To assess the performance effect, we have three realistic data sets (canada.txt, mesh.txt and synthetic.txt).
The mesh.txt data set is a scenario where we rely on Clinger's fast path so we would not expect this PR to improve performance in that case. And indeed, we see no significant difference.
For canada.txt and synthetic.txt, this PR brings substantial gains: about 2x. Further gains are possible as demonstrated by the csFastFloat library, but they would be maybe more invasive and are maybe best done by distinct pull requests.
links :
csFastFloat repo : https://github.com/CarlVerret/csFastFloat
Test data can be found here : https://github.com/CarlVerret/csFastFloat/tree/master/Benchmark/data
Benchmarks had been executed on my personnal computer
Intel Core i5-5900 2.90GHz / 12 GB Ram
under Windows 11
@EgorBo @tannergooding @lemire