On Tue, 14 Feb 2023 14:07:22 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> wrote:
>> Sorry, I overlooked those checks two times :) >> >> How about adding a moderate path like >> [this](https://github.com/plokhotnyuk/jsoniter-scala/blob/6f702ce5cae05df91b5aa6e4bd61acdf43bf18f6/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala#L1467-L1498)? >> >> I think it worth do be reused for regular parsing of `double` and `float` >> values from `String`. > > @plokhotnyuk The main goal of this PR is to avoid generating a string and > parse it, as it happens in the current implementation. The fact that it > results in being faster is only a welcome byproduct. > > The proposed patch for `doubleValue()` is only about 40 lines of code, not > counting `}`-only lines and the _extensive comments_ explaining the details > for the benefit of both reviewers and maintainers. Shorter, documented code > has a higher chance to be correct and understood. It also contributes to > simpler and quicker reviewing. > > Adding the "moderate path" to this patch would increase the code size > considerably. Moreover, I would have to invest time to understand the dense, > uncommented code and convince myself and the reviewers that it is correct. I > would also have to setup benchmarks to measure the overall benefits of adding > it to the proposed patch. And add specific tests to cover the path. > > Before that, I would prefer for this patch to be first reviewed as it is > (with possible corrections). I hope to have time to invest into your > proposals _once_ this PR is integrated into mainline. Thanks for your > patience. @rgiulietti Thanks for the explanation! I wish faster reviews of all your PRs! I bet that investigation of the moderate path will pay itself when that path will be reused for improving `java.lang.Double.parseDouble` and `java.lang.Float.parseFloat` methods. You can roughly estimate the moderate path speed up comparing the throughput of `borer` and `jsoniterScala` in the following chart. Both of them use the same fast path and fallback to `java.lang.Double.parseDouble`, the difference is that `jsoniterScala` (and `smithy4sJson` that is based on it) adds using of the moderate path: ![image](https://user-images.githubusercontent.com/890289/218768844-86d53c5f-2b4e-4326-80ae-b6301ee3c67f.png) BTW, the `jacksonScala` uses a Java port of Daniel Lemire's [fast_float](https://github.com/fastfloat/fast_float) project. ------------- PR: https://git.openjdk.org/jdk/pull/9410