-
-
Notifications
You must be signed in to change notification settings - Fork 811
BigDecimalParser.parse very slow #1153
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
Parsing BigDecimals is slow. Performance is much worse than O(n). There is not much that can be done to make it fast. Use your favourite search engine to seek out the literature. You might find that BigDecimalParser.parseWithFastParser is a little faster. BigDecimalParser.parse uses the built-in Java BigDecimal code while BigDecimalParser.parseWithFastParser uses https://github.com/wrandelshofer/FastDoubleParser You might find that BigDecimalParser.parse is faster with the latest Java releases (eg Java 21). BigDecimalParser is really an internal Jackson class and it is not recommended that it is used directly. Jackson is built to parse and write JSON (and via modules some other formats like XML and CSV). If you use a Jackson ObjectMapper, the most recent versions of Jackson limit the size of number that it will parse. This can be tweaked but the reason to limit the number of chars that Jackson will parse for numbers is precisely because of the risk that a malicious JSON file could have a very long number string in it. |
@sirnple I think you have found a bug in
|
Ok, so there may be an issue somewhere, but as @pjfanning said, But if there is a way to trigger the issue through API that'd be different story. |
Since I think this issue itself is not necessary valid (wrt passing invalid numbers), I'll close it -- but it did spawn #1157 to address possibly relevant case so it's good this was filed. |
jackson-core version: 2.15.1
I have code like this, that can't finish in time:
I have checked issue list, and I found many performance improvement, but my input still trigger an slow parse.
Additional:this input is produced by fuzz test.
The text was updated successfully, but these errors were encountered: