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

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
157 157
158 root = RootWindow (xDisplay, DefaultScreen (xDisplay));158 root = RootWindow (xDisplay, DefaultScreen (xDisplay));
159 159
160 if (!eglChooseConfig (eglDpy, eglAttrs, &config, 1, &numConfigs)) {160 if (!eglChooseConfig (eglDpy, eglAttrs, &config, 1, &numConfigs))
161 {
161 logE << "Couldn't get an EGL visual config" << std::endl;162 logE << "Couldn't get an EGL visual config" << std::endl;
162 exit(1);163 exit(1);
163 }164 }
@@ -165,7 +166,8 @@ makeXWindow (const char* name, int width, int height, int px, int py, · 1 unmodified line
165 assert (config);166 assert (config);
166 assert (numConfigs > 0);167 assert (numConfigs > 0);
167 168
168 if (!eglGetConfigAttrib (eglDpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {169 if (!eglGetConfigAttrib (eglDpy, config, EGL_NATIVE_VISUAL_ID, &vid))
170 {
169 logE << "eglGetConfigAttrib() failed" << std::endl;171 logE << "eglGetConfigAttrib() failed" << std::endl;
170 exit (1);172 exit (1);
171 }173 }
@@ -1439,6 +1441,8 @@ main (int argc, char* argv[]) · 1267 unmodified lines
1439 {1441 {
1440 if (!eglMakeCurrent (eglDpy, eglSurface, eglSurface, eglCtx))1442 if (!eglMakeCurrent (eglDpy, eglSurface, eglSurface, eglCtx))
1441 throw std::runtime_error ("Error: eglMakeCurrent() failed");1443 throw std::runtime_error ("Error: eglMakeCurrent() failed");
1444 if (!eglSwapInterval (eglDpy, 0))
1445 throw std::runtime_error ("Error: eglSwapInterval() failed");
1442 if (opts.glinfo)1446 if (opts.glinfo)
1443 printGLInfo (eglDpy);1447 printGLInfo (eglDpy);
1444 },1448 },

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