Giter Site home page Giter Site logo

Comments (5)

Alexhuszagh avatar Alexhuszagh commented on June 18, 2024 1

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.

Alexhuszagh avatar Alexhuszagh commented on June 18, 2024

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.

Alexhuszagh avatar Alexhuszagh commented on June 18, 2024

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:

  1. All the code is identical, with index and index_mut macros that use default Rust indexing by default, and with unchecked_index, disable bounds checks.
  2. Every use of index or index_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.

Alexhuszagh avatar Alexhuszagh commented on June 18, 2024

Added benchmarks in 0c45b01, this should be pushed to the latest release soon.

from rust-lexical.

Alexhuszagh avatar Alexhuszagh commented on June 18, 2024

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)

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.