History

Cut measured latency by zeroing the EGL swap interval

According to Pavel Fatin's typometer (with default settings), this change produces a significant latency reduction. No other visual impact was detected. Measured on a terminal size of standard geometry (80x24) with the default font (misc-fixed 9x18), all figures in milliseconds: On a 60Hz full-hd laptop screen: min max avg sd before 7.4 13.6 10.4 1.3 after 3.9 9.1 5.9 1.0 On a 30Hz 4K screen: min max avg sd before 5.7 39.2 14.0 4.0 after 3.8 8.5 5.1 0.9 N.B.: this latter screen had TearFree enabled, but changing that setting did not seem to affect the result. Both computers have AMD Radeon (renoir) with GLES Mesa 22.3.6 Apparently the performance becomes more consistent across refresh rates. This is only natural, as we have essentially shortcut the part of latency stemming from waiting for the next video frame. On larger terminals (more cells to update) the difference becomes less and less pronounced. On a full-screen terminal occupying the entirety of a full-hd laptop screen (at a geometry of 212x59) the impact of this commit looks like this: min max avg sd before 11.4 17.8 14.6 1.1 after 11.5 17.0 14.4 0.9 The timings diff here is probably not significant. N.B.: according to the manual page[1] of eglSwapInterval(), the interval is silently clamped to the minimum supported - which is why we just pass zero and do not bother querying EGL_MIN_SWAP_INTERVAL. [1] https://registry.khronos.org/EGL/sdk/docs/man/html/eglSwapInterval.xhtml

Tom Szilagyi committed 2 years ago

Commit 172ce071 parent f2376841 file · +6 −2Browse files

Showing the changes to src/main.cc (1 of 1 file). Show all

Unified · Split

src/main.cc+6−2
@@ -157,7 +157,8 @@ makeXWindow (const char* name, int width, int height, int px, int py, · 156 unmodified lines
157157
158158 root = RootWindow (xDisplay, DefaultScreen (xDisplay));
159159
160− if (!eglChooseConfig (eglDpy, eglAttrs, &config, 1, &numConfigs)) {
160+ if (!eglChooseConfig (eglDpy, eglAttrs, &config, 1, &numConfigs))
161+ {
161162 logE << "Couldn't get an EGL visual config" << std::endl;
162163 exit(1);
163164 }
@@ -165,7 +166,8 @@ makeXWindow (const char* name, int width, int height, int px, int py, · 1 unmodified line
165166 assert (config);
166167 assert (numConfigs > 0);
167168
168− if (!eglGetConfigAttrib (eglDpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
169+ if (!eglGetConfigAttrib (eglDpy, config, EGL_NATIVE_VISUAL_ID, &vid))
170+ {
169171 logE << "eglGetConfigAttrib() failed" << std::endl;
170172 exit (1);
171173 }
@@ -1439,6 +1441,8 @@ main (int argc, char* argv[]) · 1267 unmodified lines
14391441 {
14401442 if (!eglMakeCurrent (eglDpy, eglSurface, eglSurface, eglCtx))
14411443 throw std::runtime_error ("Error: eglMakeCurrent() failed");
1444+ if (!eglSwapInterval (eglDpy, 0))
1445+ throw std::runtime_error ("Error: eglSwapInterval() failed");
14421446 if (opts.glinfo)
14431447 printGLInfo (eglDpy);
14441448 },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t