Very slow when history gets large

Issue #746 new
Steven created an issue

I've noticed that when the history gets large, speedcrunch is slow to open and slow to produce results of calculations.

My history file is 1Mb in size, and this causes speedcrunch to freeze for 3-4 seconds for each calculation.

You can of course clear the history periodically, and this does restore full speed, but my suggestion would be an option to limit history to the last x number of entries. This would ensure you always have recent history and good performance.

For reference: Version 0.12 running on an SSD on Windows 10.

Comments (16)

  1. Michael Witrant

    That's why my speedcrunch was so slow! It used to take 1 second or 2 to answer and after a history clean up it's now instant. Thank you.

  2. Pol Welter

    I remember I had come across this once before. I am sorry I did not bring it up to your attention by posting an issue about it.

    IIRC, what's slowing us down is that the syntax highlighter re-highlights the entire document every time a new expression is evaluated. Obviously this will become costly when the history is long enough...

  3. multiwebinc

    Note, this bug also makes initial loading times significantly longer as well. What about having a setting somewhere to limit the history to a certain number of entries? As it is now, it's either an all or nothing sort of thing, either remembering an infinite amount of history or not remembering it at all.

  4. Martin Meier

    I also realized it takes some time to switch number bases/display when history is large, probably because its recalculating/transforming everything.

    About clearing history, it would be interesting to keep equation and variables definitions, otherwise one would easily loose its definition.

  5. Nate Houghton

    I ran into the same issue @martinbra (number base display changes taking an extremely long time to be displayed with a large history). With the proposed change, equation and variable definition behavior should be unmodified, as they are already stored in a separate part of the json session file (separate from the history), so it should work as you described.

  6. Rinus van Vliet

    Already annoyingly laggy with ~1sec. @50kb plain text history. But I now finally understand the reason. Never thought altering a few bits of history being such a consumer of resources though.

    Clearing the history immediately cured my annoyance. Nice because I like and am quite used to SC.

  7. Adrien Haage

    Just came across this report, as I was searching for solutions to the very slow behavior of SpeedCrunch 0.12.

    I tried to clear the history, and magically the app became fast again!

    So just wanted to report that this is still not fixed, in case it can help someone else.

  8. Lonnie Best

    Same issue.

    I like that SpeedCrunch keeps my entire history between sessions. I wish there was a way to output new calculations immediately (without it having to re-perform syntax highlighting on the entire history, on a per calculation basis).

    In JavaScript web development, each entry would be compartmentalize as separate element, and the syntax highlighting could be performed asynchronously in for await loop. You could perform syntax highlighting from the bottom up, and that task would never delay the output of the current calculation from being displayed immediately. Actually, in web application, there would never be any need to perform syntax highlight more than once per entry (per session).

    I realized that this is not a web application, but it doesn’t hurt to compare it with one; it might give someone an idea.

  9. Nate Houghton

    I wish there was a way to output new calculations immediately (without it having to re-perform syntax highlighting on the entire history, on a per calculation basis).

    The pull request I raised earlier in the thread (on 2021-01-23) addresses this also, so that appends to the history are instant (even if it has become quite long).

  10. Log in to comment