Improve throughput a little#521
Merged
Merged
Conversation
A number of functions called by VscrnScrollPage acquire and release the vscrn mutex even though VscrnScrollPage already does this, making it a bit of a waste of time. So don't do that anymore.
KUI builds never wait on the vscreen dirty semaphore - they just check each time the render timer fires if the vscreen is dirty and needs to be painted. And it turns out semaphores are a kind of expensive way to store a boolean value - when processing large amounts of input, K95 spends about half of its time just setting the vscreen dirty semaphore. So instead for KUI builds we'll try just using an integer. Whenever the vscreen is made dirty, the integer is incremented. And whenever the KUI render timer fires, it checks if this integers value is the same as the last time it looked. If the integer value has changed, the vscreen contents will have as well so its time to paint. This seems to work fine, and it doubles throughput. K95G can now sink 10MB of text in around 2.8 seconds over SSH (telnet is slower due to locking around the local echo buffer)
in some places for thread synchronisation around TCPIP sockets and the Local Echo buffer. These are implemented in userspace so have much lower overhead than mutexes provided by the kernel if there is low contention. This improves throughput for telnet and probably other non-SSH TCP/IP connections by around 5x bringing to around the same speed as SSH which doesn't currently use K95s TCP/IP connection management stuff.
# Conflicts: # kermit/k95/feature_flags.mak # kermit/k95/kui/makefile
…bled. While the functions themselves check before acting, it's a waste of time calling them for every single character received if we know they're not going to do anything.
As VscrnGetLineFromTop just wraps VscrnGetPageLineFromTop.
…(50fps) K95 has shipped with a k95custom.ini file that changes the setting to 20ms/50fps four years now, and I've not heard of any trouble or observed any myself.
The design of the new implementation is based on the way the SSH subsystem shuffles data between threads, and it reuses its ringbuffer implementation. This provides for a speedup of over 80x for terminal throughput. I've run a few file transfers through it and used a terminal session through it both (PTY and PIPE), and it all seems to work fine. The design is the same as the SSH subsystem, so if there are any major issues with the design I expect they'd have already surfaced over there by now.
d48b72c to
9de463d
Compare
… an SSH DLL or the main application
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR builds on previous work done late last year to improve throughput a little by:
CRITICAL_SECTIONinstead of mutexes for the TCP/IP socket, Local Echo Buffer and SSH ring buffer improving throughput for SSH connections a little and non-SSH connections quite drastically.This cuts the time it takes to handle a 10MB text file being dumped to the terminal from 5.94 to 1.7 seconds for SSH, and 15.59 to 1.9 seconds for telnet. PTY/pipe throughput is now about the same as SSH.
For comparison:
~1.7 seconds is probably fine - no one can read that fast, so its really about making sure accidentally catting a huge log file doesn't cause problems (which it absolutely does in the current K95 release).
I don't see any other obvious low hanging fruit at this point. Any further gains in throughput will probably come down to minor tweaks that individually only make a very small difference. Based on some further experimentation with the profiler, probably things like:
TODO: