Improved render performance implementation to use a fork of alacritty which includes the last # of bytes processed as a way of estimating throughput in cases where the terminal output is chanegd in place

This commit is contained in:
Mikayla Maki 2022-07-28 16:03:00 -07:00
parent 81cbdcfd11
commit 8471af5a7d
3 changed files with 12 additions and 13 deletions

4
Cargo.lock generated
View file

@ -62,7 +62,7 @@ dependencies = [
[[package]]
name = "alacritty_config_derive"
version = "0.1.0"
source = "git+https://github.com/zed-industries/alacritty?rev=382e1892c4eaae7d45ec6ea580db47242ec66e31#382e1892c4eaae7d45ec6ea580db47242ec66e31"
source = "git+https://github.com/zed-industries/alacritty?rev=ba56f545e3e3606af0112c6bdfe998baf7faab50#ba56f545e3e3606af0112c6bdfe998baf7faab50"
dependencies = [
"proc-macro2",
"quote",
@ -72,7 +72,7 @@ dependencies = [
[[package]]
name = "alacritty_terminal"
version = "0.17.0-dev"
source = "git+https://github.com/zed-industries/alacritty?rev=382e1892c4eaae7d45ec6ea580db47242ec66e31#382e1892c4eaae7d45ec6ea580db47242ec66e31"
source = "git+https://github.com/zed-industries/alacritty?rev=ba56f545e3e3606af0112c6bdfe998baf7faab50#ba56f545e3e3606af0112c6bdfe998baf7faab50"
dependencies = [
"alacritty_config_derive",
"base64 0.13.0",

View file

@ -8,7 +8,7 @@ path = "src/terminal.rs"
doctest = false
[dependencies]
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "382e1892c4eaae7d45ec6ea580db47242ec66e31"}
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "ba56f545e3e3606af0112c6bdfe998baf7faab50"}
editor = { path = "../editor" }
util = { path = "../util" }
gpui = { path = "../gpui" }

View file

@ -13,7 +13,7 @@ use alacritty_terminal::{
ansi::{ClearMode, Handler},
config::{Config, Program, PtyConfig, Scrolling},
event::{Event as AlacTermEvent, EventListener, Notify, WindowSize},
event_loop::{EventLoop, Msg, Notifier},
event_loop::{EventLoop, Msg, Notifier, READ_BUFFER_SIZE},
grid::{Dimensions, Scroll},
index::{Direction, Point},
selection::{Selection, SelectionType},
@ -55,7 +55,7 @@ const DEBUG_TERMINAL_WIDTH: f32 = 500.;
const DEBUG_TERMINAL_HEIGHT: f32 = 30.; //This needs to be wide enough that the CI & a local dev's prompt can fill the whole space.
const DEBUG_CELL_WIDTH: f32 = 5.;
const DEBUG_LINE_HEIGHT: f32 = 5.;
const MAX_FRAME_RATE: f32 = 120.;
const MAX_FRAME_RATE: f32 = 60.;
const BACK_BUFFER_SIZE: usize = 5000;
///Upward flowing events, for changing the title and such
@ -412,7 +412,7 @@ impl Terminal {
///Tells the render loop how many frames to skip before reading from the terminal.
fn frames_to_skip(&self) -> usize {
self.frames_to_skip
0 //self.frames_to_skip
}
fn push_events(&mut self, events: Vec<AlacTermEvent>) {
@ -570,17 +570,16 @@ impl Terminal {
self.process_terminal_event(&e, &mut term, cx)
}
let buffer_velocity = term.grid().history_size().saturating_sub(BACK_BUFFER_SIZE);
let fractional_velocity = buffer_velocity as f32 / BACK_BUFFER_SIZE as f32;
//TODO: determine a better metric for this
let buffer_velocity =
(term.last_processed_bytes() as f32 / (READ_BUFFER_SIZE as f32 / 4.)).clamp(0., 1.);
//2nd power
let scaled_fraction = fractional_velocity * fractional_velocity;
let scaled_velocity = buffer_velocity * buffer_velocity;
self.frames_to_skip = (scaled_fraction * (Self::default_fps() / 10.)).round() as usize;
self.frames_to_skip = (scaled_velocity * (Self::default_fps() / 10.)).round() as usize;
term.grid_mut().update_history(BACK_BUFFER_SIZE); //Clear out the measurement space
term.grid_mut().update_history(BACK_BUFFER_SIZE * 2); //Extra space for measuring
term.set_last_processed_bytes(0); //Clear it in case no reads between this lock and the next.
let content = term.renderable_content();