-
Notifications
You must be signed in to change notification settings - Fork 5k
Should JIT recognize and hoist NumberFormatInfo.CurrentInfo calls when parsing numbers? #11444
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
Comments
It's obvious to us humans that the parsing code won't change the current culture but this isn't something that the JIT can figure out without interprocedural analysis. In general, calls cannot be hoisted, with the exception of a few special helper calls that the JIT knows that they're "pure". |
Other threads can change the current culture though. The current culture is a very complex algorithm with many fallbacks. I think we can make this better by:
Also, you may want to consider using the newer Utf8 parsers for any high-performance parsing since you probably got the input as Utf8 anyway and do not care about any of the current sensitive parsing. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
I am currently profiling ML.NET to search for some perf bottlenecks and places where we could do a better job.
One of the patterns I have found is following: parsing numbers in a loop causes a call to
NumberFormatInfo.CurrentInfo
per loop iteration if theFormatInfo
is not provided in explicit way.I have done manual hoisting in ML.NET and I saved 8% for huge file reads (gigabytes of data) (more info here dotnet/machinelearning#1599)
My proposal: JIT could recognize such pattern and hoist the result of
NumberFormatInfo.CurrentInfo
.Some benchmarks results:
Benchmark code:
cc @danmosemsft @tannergooding @AndyAyersMS @CarolEidt @davidwrighton
The text was updated successfully, but these errors were encountered: