This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-11-parser-speedup
in repository terminology.
View the commit online.
commit dac9a23828fb26ccf4bc331d8934aa253304ea73
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 14:38:41 2026 -0600
termpty: keep the debug log level instead of asking eina each time
The parser checks whether debug logging is on for every sequence and
every text run, and each check was a call into libeina. Keep the answer
in a flag read again by termpty_init() and termpty_new(); a level set
later applies to the terminals created after it. Nothing in Terminology
changes the level of the termpty domain at run time, and
EINA_LOG_LEVELS=termpty:4 is read when the domain is registered.
tybench, cycles per input byte, 7 interleaved rounds: csi-motion
-9.4% (24.50 from 27.06), truecolor-cells -9.8%, sgr -6.5%, insert
-6.9%, insert-mode -5.6%, scroll-region -5.0%, fill -5.0%, rep -4.0%.
strings reads +6.4% with no more instructions per byte (31.4 -> 31.3),
which is code layout. No other corpus is slower.
---
src/bin/termpty.c | 36 ++++++++++++++++++++++++++++++++++++
src/bin/termpty.h | 11 +++++++++--
src/bin/termptyesc.c | 5 +----
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
5 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 106bb926..a6c7dc45 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -40,6 +40,7 @@
/* specific log domain to help debug only terminal code parser */
int _termpty_log_dom = -1;
+Eina_Bool termpty_log_dbg_enabled = EINA_FALSE;
#undef CRITICAL
#undef ERR
@@ -53,6 +54,15 @@ int _termpty_log_dom = -1;
#define INF(...) EINA_LOG_DOM_INFO(_termpty_log_dom, __VA_ARGS__)
#define DBG(...) TERMPTY_DBG(__VA_ARGS__)
+void
+termpty_log_level_refresh(void)
+{
+ /* Binaries that compile logging out never register the domain, so asking
+ * about its level would trip eina's safety check. */
+ termpty_log_dbg_enabled = (_termpty_log_dom >= 0) &&
+ eina_log_domain_level_check(_termpty_log_dom, EINA_LOG_LEVEL_DBG);
+}
+
void
termpty_init(void)
{
@@ -63,6 +73,7 @@ termpty_init(void)
_termpty_log_dom = eina_log_domain_register("termpty", NULL);
if (_termpty_log_dom < 0)
EINA_LOG_CRIT("Could not create logging domain '%s'", "termpty");
+ termpty_log_level_refresh();
}
void
@@ -71,6 +82,7 @@ termpty_shutdown(void)
if (_termpty_log_dom < 0) return;
eina_log_domain_unregister(_termpty_log_dom);
_termpty_log_dom = -1;
+ termpty_log_dbg_enabled = EINA_FALSE;
}
@@ -554,6 +566,7 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
ty = calloc(1, sizeof(Termpty));
if (!ty) return NULL;
+ termpty_log_level_refresh();
ty->config = config;
ty->w = w;
ty->h = h;
@@ -4534,6 +4547,29 @@ tytest_termpty_read_error(void)
}
#endif
+#if defined(BINARY_TYTEST)
+int
+tytest_termpty_log_level(void)
+{
+ termpty_init();
+ assert(_termpty_log_dom >= 0);
+
+ eina_log_domain_level_set("termpty", EINA_LOG_LEVEL_WARN);
+ termpty_log_level_refresh();
+ assert(!termpty_log_dbg_enabled);
+
+ eina_log_domain_level_set("termpty", EINA_LOG_LEVEL_DBG);
+ termpty_log_level_refresh();
+ assert(termpty_log_dbg_enabled);
+
+ termpty_shutdown();
+ assert(!termpty_log_dbg_enabled);
+ termpty_log_level_refresh();
+ assert(!termpty_log_dbg_enabled);
+ return 0;
+}
+#endif
+
#if defined(BINARY_TYTEST)
/* Each OSC 8 frees the string it decodes, valid or not: run under ASan,
* a leak fails the test. */
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index d03515cf..31889a65 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -525,6 +525,14 @@ termpty_selection_read_answer(Termpty *ty,
Termpty_Selection_Read_Answer answer);
extern int _termpty_log_dom;
+/* Whether the termpty domain logs at the debug level. Asking eina costs a call
+ * into libeina each time, and the parser asks for every sequence, so the
+ * answer is kept here. */
+extern Eina_Bool termpty_log_dbg_enabled;
+/* Reads the debug level of the termpty domain again. Done by termpty_init()
+ * and termpty_new(): a level set afterwards, with eina_log_domain_level_set()
+ * for example, applies to the terminals created from then on. */
+void termpty_log_level_refresh(void);
/* Debug logging for the parser. EINA_LOG_DOM_DBG() evaluates its arguments
* before the level is checked, which is too expensive for the hot paths, so
@@ -536,8 +544,7 @@ extern int _termpty_log_dom;
# define TERMPTY_DBG(...) \
do \
{ \
- if (EINA_UNLIKELY(eina_log_domain_level_check(_termpty_log_dom, \
- EINA_LOG_LEVEL_DBG))) \
+ if (EINA_UNLIKELY(termpty_log_dbg_enabled)) \
EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__); \
} \
while (0)
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index ab21a53e..a0291833 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -120,10 +120,7 @@ _log_text_run(const Eina_Unicode *c, int len)
char buf[512];
int i, n = 0;
- /* Binaries that compile logging out never register the domain, so asking
- * about its level would trip eina's safety check. */
- if (EINA_LIKELY(!eina_log_domain_level_check(_termpty_log_dom,
- EINA_LOG_LEVEL_DBG)))
+ if (EINA_LIKELY(!termpty_log_dbg_enabled))
return;
for (i = 0; i < len; i++)
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 1d935282..c5361baf 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -170,6 +170,7 @@ static struct {
{ "osc52_long_max", tytest_osc52_long_max},
{ "ty_escape_max", tytest_ty_escape_max},
{ "osc_arg_get", tytest_osc_arg_get},
+ { "termpty_log_level", tytest_termpty_log_level},
{ "osc_color_reset", tytest_osc_color_reset},
{ "osc_color_name", tytest_osc_color_name},
{ "xterm_parse_color", tytest_xterm_parse_color},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index face6b9e..e282a68f 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -125,6 +125,7 @@ int tytest_osc52_read_ask(void);
int tytest_osc52_long_max(void);
int tytest_ty_escape_max(void);
int tytest_osc_arg_get(void);
+int tytest_termpty_log_level(void);
int tytest_osc_color_reset(void);
int tytest_osc_color_name(void);
int tytest_xterm_parse_color(void);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.