-
Notifications
You must be signed in to change notification settings - Fork 3
A super hacky attempt at using $kak_command_fifo instead of a socket connection #15
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
Draft
Screwtapello
wants to merge
1
commit into
caksoylar:master
Choose a base branch
from
Screwtapello:command-fifo-hack
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question here since I don't grok response fifo very well: Is it strictly necessary to have
kakwrite to the response fifo and us read it for this to work, or is it just to make surekakfinished processing before we send another event? If it is the latter, would the throughput improve if we remove it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin has a "duration" option, but unless there's some way for us to measure how long Kakoune spends doing stuff, we're only measuring the duration of sending messages, not the duration of the actual animation. Telling Kakoune to write to
$kak_response_fifoafter processing the message, and waiting for it to do so, gives us the timing information we need.Deleting it slowed things way down for me - instead of drawing two or three frames over the intended quarter-second, it drew a smoother 5-10 frames over a full second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the point of getting more accurate timing information about the actual change; I assume below is what is happening if Kakoune cannot process the command inside
intervalduration:interval. I assume themax_durationcondition is triggered after a few scroll events, so it will finish in a quarter second by jumping to the end.intervalis elapsed, but send a new event immediately after it is elapse. We might end up just sending all scroll events one-by-one and never triggermax_duration. So we queue up many scroll events instead and Kakoune gets backed up and takes time to finish up the queue.In hindsight this issue is present in the original implementation as well, but I guess the scroll event is just faster to complete Kakoune-side? I don't know if writing to response fifo would slow it down much, or
<c-l>is costlier than the regular screen redraw Kakoune makes on a line scroll. I can try to benchmark the cost of these Kakoune-side and see if it is much significantly than just executingexec jvj.Another idea: Since in this case we can know how long a scroll event exactly takes, we could actually try to play catch up by sending intermediate scroll events for multiple lines at once, when we determine we are behind timingwise. The bookkeeping to do that doesn't seem very trivial though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should note I've been testing on a tiny, slow netbook, so any performance problems would be magnified. The original "blast keys at the socket" implementation is actually pretty smooth, but the implementation in this PR is basically unusable (one of the reasons it's a draft PR).
vkprobably just redraws a single line, while<c-l>redraws the entire screen so it can recover from "the screen isn't in the state Kakoune thinks it's in". This can be a significant difference on a big terminal, but my little laptop only has a 720p display so I'm not using a very big terminal, I'd be a little surprised if this were a big issue.Animation timing is a whole thing, yeah. If you're lucky enough that drawing a frame is reliably faster than the delay between frames, then yeah, you don't have to worry too much. On the other hand, if you can't reliably meet your target frame rate, you need to structure your calculation so that the "time" unit is seconds, not frames. Once that's done, it shouldn't be too complex to say "at time t we should have scrolled 7 lines, so far we have scrolled 2, therefore we need to scroll 7-2 = 5 additional lines"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my relatively beefy desktop I didn't see too much performance difference, but I see some overshooting with page scroll keys which shouldn't really be caused by this change (unless there is some issue with Kakoune's command fifo processing). I think I'll need to do some debugging and see what's going on :/
Right, if we restructure the code by precomputing the cumulative intervals and storing them, then looking it up at every step your suggestion should work for catching up.
By the way it might help for you to bump up the
SEND_INTERVALconstant on a slower machine, so that at the very least the initial lines would be grouped up in larger batches. It doesn't really help with catching up once behind but at least it would make it harder to fall behind.