1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-26 23:18:50 +00:00

Remove event watermarks, don't work well enough to be worth it.

This commit is contained in:
nicm 2017-02-08 08:25:12 +00:00
parent c0a34821c1
commit 35a0606de1
2 changed files with 5 additions and 41 deletions

19
tmux.h
View File

@ -64,18 +64,8 @@ struct tmuxproc;
/* Automatic name refresh interval, in microseconds. Must be < 1 second. */ /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
#define NAME_INTERVAL 500000 #define NAME_INTERVAL 500000
/* /* Maximum size of data to hold from a pane. */
* Event watermarks. We start with FAST then if we hit full size for HITS reads #define READ_SIZE 4096
* in succession switch to SLOW, and return when we hit EMPTY the same number
* of times.
*/
#define READ_FAST_SIZE 4096
#define READ_SLOW_SIZE 128
#define READ_FULL_SIZE (4096 - 16)
#define READ_EMPTY_SIZE 16
#define READ_CHANGE_HITS 3
/* Attribute to make GCC check printf-like arguments. */ /* Attribute to make GCC check printf-like arguments. */
#define printflike(a, b) __attribute__ ((format (printf, a, b))) #define printflike(a, b) __attribute__ ((format (printf, a, b)))
@ -240,7 +230,7 @@ enum tty_code_code {
TTYC_DL1, /* delete_line, dl */ TTYC_DL1, /* delete_line, dl */
TTYC_E3, TTYC_E3,
TTYC_ECH, /* erase_chars, ec */ TTYC_ECH, /* erase_chars, ec */
TTYC_ED, /* csr_eos, cd */ TTYC_ED, /* clr_eos, cd */
TTYC_EL, /* clr_eol, ce */ TTYC_EL, /* clr_eol, ce */
TTYC_EL1, /* clr_bol, cb */ TTYC_EL1, /* clr_bol, cb */
TTYC_ENACS, /* ena_acs, eA */ TTYC_ENACS, /* ena_acs, eA */
@ -762,9 +752,6 @@ struct window_pane {
struct event resize_timer; struct event resize_timer;
u_int wmark_size;
u_int wmark_hits;
struct input_ctx *ictx; struct input_ctx *ictx;
struct grid_cell colgc; struct grid_cell colgc;

View File

@ -66,8 +66,6 @@ static struct window_pane *window_pane_create(struct window *, u_int, u_int,
u_int); u_int);
static void window_pane_destroy(struct window_pane *); static void window_pane_destroy(struct window_pane *);
static void window_pane_set_watermark(struct window_pane *, size_t);
static void window_pane_read_callback(struct bufferevent *, void *); static void window_pane_read_callback(struct bufferevent *, void *);
static void window_pane_error_callback(struct bufferevent *, short, void *); static void window_pane_error_callback(struct bufferevent *, short, void *);
@ -839,14 +837,6 @@ window_pane_destroy(struct window_pane *wp)
free(wp); free(wp);
} }
static void
window_pane_set_watermark(struct window_pane *wp, size_t size)
{
wp->wmark_hits = 0;
wp->wmark_size = size;
bufferevent_setwatermark(wp->event, EV_READ, 0, size);
}
int int
window_pane_spawn(struct window_pane *wp, int argc, char **argv, window_pane_spawn(struct window_pane *wp, int argc, char **argv,
const char *path, const char *shell, const char *cwd, struct environ *env, const char *path, const char *shell, const char *cwd, struct environ *env,
@ -954,7 +944,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
wp->event = bufferevent_new(wp->fd, window_pane_read_callback, NULL, wp->event = bufferevent_new(wp->fd, window_pane_read_callback, NULL,
window_pane_error_callback, wp); window_pane_error_callback, wp);
window_pane_set_watermark(wp, READ_FAST_SIZE); bufferevent_setwatermark(wp->event, EV_READ, 0, READ_SIZE);
bufferevent_enable(wp->event, EV_READ|EV_WRITE); bufferevent_enable(wp->event, EV_READ|EV_WRITE);
free(cmd); free(cmd);
@ -970,26 +960,13 @@ window_pane_read_callback(__unused struct bufferevent *bufev, void *data)
char *new_data; char *new_data;
size_t new_size; size_t new_size;
if (wp->wmark_size == READ_FAST_SIZE) {
if (size > READ_FULL_SIZE)
wp->wmark_hits++;
if (wp->wmark_hits == READ_CHANGE_HITS)
window_pane_set_watermark(wp, READ_SLOW_SIZE);
} else if (wp->wmark_size == READ_SLOW_SIZE) {
if (size < READ_EMPTY_SIZE)
wp->wmark_hits++;
if (wp->wmark_hits == READ_CHANGE_HITS)
window_pane_set_watermark(wp, READ_FAST_SIZE);
}
log_debug("%%%u has %zu bytes (of %u, %u hits)", wp->id, size,
wp->wmark_size, wp->wmark_hits);
new_size = size - wp->pipe_off; new_size = size - wp->pipe_off;
if (wp->pipe_fd != -1 && new_size > 0) { if (wp->pipe_fd != -1 && new_size > 0) {
new_data = EVBUFFER_DATA(evb) + wp->pipe_off; new_data = EVBUFFER_DATA(evb) + wp->pipe_off;
bufferevent_write(wp->pipe_event, new_data, new_size); bufferevent_write(wp->pipe_event, new_data, new_size);
} }
log_debug("%%%u has %zu bytes", wp->id, size);
input_parse(wp); input_parse(wp);
wp->pipe_off = EVBUFFER_LENGTH(evb); wp->pipe_off = EVBUFFER_LENGTH(evb);