Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mainloop-] during replay, redraw less often #2369

Merged
merged 4 commits into from May 22, 2024

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Apr 3, 2024

When replaying commands, visidata 3.0 versions are noticeably slower to load some large sheets than v2.11 was. It's caused by redrawing the screen too often. The symptom to look for is that the progress (% loading…) is updated dozens of times per second.

Sometimes the quick updates are steady. For other files they come and go in short bursts, then doing proper slower updating for longer stretches. Only the short bursts of quick updates will cause slower loading.

Here is a case that, on my system, consistently exhibits the problem.

seq 2000111 > 2m.tsv
# interactive mode:  quit.vdj is a timing helper script that opens 2m.tsv and immediately quits
=time vd -p quit.vdj
6.63user

After applying 02432ff:

=time vd.fixed -p quit.vdj
5.12user

quit.vdj.txt

In this case the bug causes 30% slower loading. It causes the screen to be drawn 37 times per second, vs the fixed version that draws 7 times per second.

While I was patching mainloop, I also fixed an off-by-one error in counting idle timeouts (51421d9). The effect will be ~9% fewer recalculations of columns when idling. To demonstrate the change: echo a |vd then make an ExprColumn: =vd.status('test'). For each row in the column, the ExprColumn will be calculated once, and then recalculated once after every timeout. Before the fix, in v3.0.2 it will output 12 lines to the status bar, and after the fix, only 11.

--

Edited to add: it turns out this PR also closes #2274. In that bug, editCell queues commands in _nextCommands, triggering the same high rate of redrawing.

@midichef midichef changed the title [mainloop-] stop mainloop from running too often [mainloop-] during replay, redraw less often Apr 23, 2024
Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, thanks for fixing it!

anjakefala added a commit to midichef/visidata that referenced this pull request May 22, 2024
@anjakefala anjakefala merged commit 033c65c into saulpw:develop May 22, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[input] screen flickers in edit-cell
3 participants