mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 14:00:03 +00:00
perf: reduced pty bufferization window
This commit is contained in:
parent
50ab4fc37e
commit
2e6acd2fa1
@ -11,8 +11,11 @@ module.exports = function patchPTYModule (mod) {
|
|||||||
let lastFlush = 0
|
let lastFlush = 0
|
||||||
let nextTimeout = 0
|
let nextTimeout = 0
|
||||||
|
|
||||||
const maxWindow = 250
|
// Minimum prebuffering window (ms) if the input is non-stop flowing
|
||||||
const minWindow = 50
|
const minWindow = 10
|
||||||
|
|
||||||
|
// Maximum buffering time (ms) until output must be flushed unconditionally
|
||||||
|
const maxWindow = 100
|
||||||
|
|
||||||
function flush () {
|
function flush () {
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
@ -36,9 +39,11 @@ module.exports = function patchPTYModule (mod) {
|
|||||||
terminal.on('data', data => {
|
terminal.on('data', data => {
|
||||||
buffer += data
|
buffer += data
|
||||||
if (Date.now() - lastFlush > maxWindow) {
|
if (Date.now() - lastFlush > maxWindow) {
|
||||||
|
// Taking too much time buffering, flush to keep things interactive
|
||||||
flush()
|
flush()
|
||||||
} else {
|
} else {
|
||||||
if (Date.now() > nextTimeout - (minWindow / 10)) {
|
if (Date.now() > nextTimeout - (maxWindow / 10)) {
|
||||||
|
// Extend the window if it's expiring
|
||||||
reschedule()
|
reschedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user