1whatleytay / saturn

A modern MIPS interpreter and assembler.
MIT License
29 stars 6 forks source link

Lag with large horizontal line #9

Open AlekseyPanas opened 1 year ago

AlekseyPanas commented 1 year ago

I used a script to generate a bitmap and pasted the line into Saturn, which was about 46000. When you are scrolled far from the line, it doesn't render so everything is fine. When you get close to the line and it is rendered, the editor gets noticeably slower. It's still completely usable, but a few more of those lines and it might really start choking up.

Consider optimizing it so that very long lines aren't fully rendered if they are off screen.

Edit: Can confirm that I made Saturn cry. Another long line and it became very very slow

1whatleytay commented 1 year ago

Yep. Virtualization is done vertically but not done horizontally. Horizontal virtualization is much more challenging because not all characters are the same length (tabs are longer than spaces, etc.) so it's difficult to tell mathematically what the user can see (might be able to be done with some kind of binary search, but these are significantly more expensive to do).

You'll also notice as a consequence of vertical virtualization that you can only scroll left/right when you have long lines in proximity (this doesn't affect usability too much so I ended up leaving it in).

I recommend splitting your lines in the bitmap generator you use if possible! There are many other things in Saturn that deal with lines as units (lexing/syntax highlighting, undo/redo) and long lines can impact performance in other ways too.

Screenshot 2023-04-03 at 12 03 11 PM

Additionally, if you know some Javascript and HTML and you're interested in tinkering with the project, we welcome pull requests (for anything)! I'm trying to work on as much as I can, but I'm only one person and it's tough to get to everything.

AlekseyPanas commented 1 year ago

Oh I didn't know you could split lines like that. Thanks!

I actually did want to contribute to this project! I have it on my backlog to try to implement collapsable blocks.