Comments (6)
(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.
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.
@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.
@wrandelshofer yeah sorry I didn't notice, output in README was not from jmh this is why :(
from fastdoubleparser.
@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.
I have made the code now allocation free on the happy path in revision 343e4ae.
from fastdoubleparser.
Related Issues (20)
- FastDoubleParser doesn't support all input formats as the default OpenJDK Float/Double parsers HOT 10
- The parser throws StringIndexOutOfBoundsException/ArrayIndexOutOfBoundsException for some inputs HOT 6
- BigDecimal parser HOT 12
- Publish a multi-release JAR HOT 2
- Parsing of hexadecimal floating point numbers is broken in release 0.5.0 HOT 1
- Publish 0.5.2 to maven central HOT 2
- BigInteger parser HOT 6
- possible performance issue with very big doubles HOT 25
- Builds should be reproducible HOT 1
- Is this a mistake with hex float parsing? HOT 1
- Incorrect maven command sequence HOT 6
- Please bundle LICENSE/NOTICE files in the produced jar files HOT 49
- Implement faster slow path for double parser (JDK 21)
- Document which code signing keys will be used for published artifacts. HOT 2
- issue with module-info classes in v0.9.0 release HOT 3
- More efficient character group check HOT 1
- Bug: the highest bit of hexadecimal float significand ignored HOT 1
- Parser accepts invalid hex chars HOT 2
- NPE in "FastDoubleParser", method "JavaBigDecimalParser.parseBigDecimal()" HOT 1
- 1.0.0 release only supports very recent JVMs HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastdoubleparser.