Giter Site home page Giter Site logo

Comments (6)

lemire avatar lemire commented on July 20, 2024

(Note that I am not one of the authors of this library, just an observer.)

why allocate here??

Are you sure that there is heap allocation? What does escape analysis reveals?

lack of jmh tests is also troubling :(

Presumably, you are unsatisfied by DoubleParserJmhBenchmark.java?

from fastdoubleparser.

wrandelshofer avatar wrandelshofer commented on July 20, 2024

Hi nevgeniev,

I did indeed implement a variant with a NaN that used some of the available bits in the NaN to encode that we need to go over the slow path. However this did not improve performance. It just made the code more complex.
Heap allocation occurs actually only in interpreted mode. The JIT inlines the called method and then removes the allocation. - In the use cases, in which I use FastDoubleParser, there is no point in optimizing interpreted mode.

Actually, there are jmh benchmarks in the test/jmh/java folder.

from fastdoubleparser.

nevgeniev avatar nevgeniev commented on July 20, 2024

@lemire ea could be very fragile actually... for it to work function allocating Double needs to be inlined first. And for this to happen certain hotspot threshold must not be hit. (max number of instructions already inlined and inlined stack depth) if those threshold were hit, hotspot will just stop inlining, so function allocating Double will become just a function call and actuall allocation would happen at least this is my understanding :).

     intx MaxInlineLevel                           = 9                                         {product} {default}
     intx MaxInlineSize                            = 35                                        {product} {default}
     intx MaxRecursiveInlineLevel                  = 1                                         {product} {default}

For example because of that effect Unsafe in latest jdk versions works slower for some libraries (stacks just became deeper as sun.misc.Unsafe became a facade rather than real Unsafe).. and to win performance back you need to adjust those thresholds

What I'm trying to say is that function relying on EA to be alloc free could be placed in context where hotspot won't be able to do inlining and eliminate allocation

tl;dr, personally I prefer to make code explicitly alloc free whenever is possible to avoid surprises

from fastdoubleparser.

nevgeniev avatar nevgeniev commented on July 20, 2024

@wrandelshofer yeah sorry I didn't notice, output in README was not from jmh this is why :(

from fastdoubleparser.

lemire avatar lemire commented on July 20, 2024

@nevgeniev By very fragile... you mean that it is easy to cause heap allocation, even in the case where the function is called enough to be inlined.

This is very interesting. Can you provide me with such an example (an actual benchmark)... I'd love to take a look.

from fastdoubleparser.

wrandelshofer avatar wrandelshofer commented on July 20, 2024

I have made the code now allocation free on the happy path in revision 343e4ae.

from fastdoubleparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.