This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit bbabf089df313d5f2aefdabed21f023a48243aee
Author: Boris Faure <[email protected]>
AuthorDate: Fri Nov 6 22:15:14 2026 +0000

    termpty: fill cells by doubling copies of the first one
    
    GCC compiles the cell fill loop, dst[i] = local, by building local on
    the stack with narrow stores then reloading it as one 16-byte load,
    every iteration: the reload cannot be forwarded from the narrower
    stores, so each cell pays a store-forwarding stall. A DECALN took
    6.7 us, 3.5 ns per cell.
    
    The first cell is now written in place, field by field, and copied
    over the rest with memcpy() of doubling spans. As text appends go
    through the same fill one cell at a time, they lose their stall too.
    
    tybench, release build, best of 10 iterations, three interleaved runs,
    MB/s before -> after:
    
      fill (new corpus)   28.1 -> 39.7
      DECALN only          0.44 -> 11.6
      unicode            116.4 -> 135.1
      rep                 67.1 -> 74.0
      plain-ascii        289.5 -> 297.0
      scroll, sgr: unchanged within the noise
---
 src/bin/termpty.c |  6 ++++--
 src/bin/termpty.h | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 4cf563d0..32aae5bc 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1869,8 +1869,10 @@ termpty_cell_codepoint_att_fill(Termpty *ty, Eina_Unicode codepoint,
     * invariant as TERMPTY_CELL_COPY()'s fast path. */
    if (EINA_LIKELY((ty->hl.size == 0) && (ty->block.blocks == NULL)))
      {
-        for (i = 0; i < n; i++)
-          dst[i] = local;
+        if (n <= 0) return;
+        dst[0].codepoint = codepoint;
+        dst[0].att = att;
+        termpty_cells_replicate(dst, n);
         return;
      }
 
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 8435a022..85a60b54 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -528,6 +528,19 @@ term_link_eq(Termpty *ty, Term_Link *hl, uint16_t link_id)
     return (strcmp(hl->url, hl2->url) == 0);
 }
 
+/* Copy dst[0] over dst[1] to dst[n - 1], doubling the copied span: a
+ * per-cell struct assignment loop is compiled into a store-forwarding
+ * stall per cell. */
+static inline void
+termpty_cells_replicate(Termcell *dst, int n)
+{
+   int done;
+
+   for (done = 1; done < n; done *= 2)
+     memcpy(dst + done, dst,
+            (size_t)((done < n - done) ? done : n - done) * sizeof(*dst));
+}
+
 static inline void
 termpty_cell_fill(Termpty *ty, const Termcell *src, Termcell *dst, int n)
 {
@@ -540,8 +553,9 @@ termpty_cell_fill(Termpty *ty, const Termcell *src, Termcell *dst, int n)
      {
         if (src)
           {
-             for (i = 0; i < n; i++)
-               dst[i] = src[0];
+             if (n <= 0) return;
+             dst[0] = src[0];
+             termpty_cells_replicate(dst, n);
           }
         else
           {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to