Comments (5)
I've looked more at the differences between the two, and for a fairly rough, initial version of the float parser, I use subslices fairly extensively, which I am almost certain is incurring the performance hit. For more complex floats (those that are near halfway representations), which I was naively focusing on, the hit was fairly minimal. For simple data, it's 15-20%.
This should be trivial to fix with the same approach I used in the integer parser: simply tracking the current index.
from rust-lexical.
Let me profile with my sample data, I did notice some minor slowdowns with simple data, but I believe I might able to remediate this.
from rust-lexical.
Sorry, back from vacation, this should be fixed with the recent commit 26176a9. There's an undocumented feature unchecked_index
(I will not document it, at least not until it has been thoroughly fuzzed), which will be present in version 2.1, that will disable bounds checking for some slice indexing, that should remove these performance hits.
I tried numerous things, and found ultimately I had to disable bounds checking in a few locations. However, doing so would be a nightmare if I ever refactored the code, since any analysis I had done to demonstrate that there could not be a memory error may no longer be valid after refactoring.
To mitigate this, I have two changes:
- All the code is identical, with
index
andindex_mut
macros that use default Rust indexing by default, and withunchecked_index
, disable bounds checks. - Every use of
index
orindex_mut
is elaborately explained, to help avoid refactoring from leading to memory errors.
For example, one of the comments is as follows:
// This is always safe, since the table is 2*radix^2, and the value
// must <= radix^2, so rem must be in the range [0, 2*radix^2-1).
from rust-lexical.
Added benchmarks in 0c45b01, this should be pushed to the latest release soon.
from rust-lexical.
Live as of lexical v2.1 and lexical-core v0.4.
You may use the feature unchecked_index
to disable index checking in slices, which should restore this performance. This undocumented, but considered to be part of the public API, and therefore stable.
from rust-lexical.
Related Issues (20)
- [OTHER] Improve internal safety comments and architecture
- [BUG] Unsoundness: `try_parse_{4,8}digits` appear to advance iterators out of bounds
- [BUG] Unsoundness in `Bytes::read()` HOT 1
- [BUG] BytesIter should be an `unsafe trait` or private
- [BUG] Bounds for integer parsing are not correctly checked HOT 1
- [FEATURE] Update Dragonbox Algorithm HOT 2
- [BUG] `umul192_lower128` can error on due to overflow on addition
- [FEATURE] Add thousands digit separator for ```WriteIntegerOptions``` to use with ```to_string_with_options```
- parse_partial ignoring minus sign in presence of trailing characters HOT 3
- [BUG] Assertion failure on parsing hexadecimal floats HOT 1
- [BUG] Tests fail to compile because quickcheck is missing from Cargo.toml in the crates.io tarball. HOT 4
- [QUESTION] Use of min_significant_digits with max_significant digits
- [BUG] Integer overflow checking logic is incorrect
- [FEATURE] `write` APIs should take `buffer: &mut [MaybeUninit<u8>]`
- [QUESTION] support custom types (i256)
- [BUG] -0.0 printed as "0.0" HOT 1
- [BUG] Safety comments for MaybeUninit::assume_init calls are wrong, calls are UB
- [BUG] consecutive_digit_separator has no effect
- [BUG] Inconsistent error between int and float parsing
- [BUG] `no_integer_leading_zeros(true)` incorrectly parses input
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 rust-lexical.