<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/shm.c, branch 1.4.3</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.4.3</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.4.3'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2020-06-04T13:39:19Z</updated>
<entry>
<title>render: re-write cell clipping to use pixman destination clipping</title>
<updated>2020-06-04T13:39:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-06-04T13:39:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8b320ed29630e75c058bbf368ea5e2e9a68d0143'/>
<id>urn:sha1:8b320ed29630e75c058bbf368ea5e2e9a68d0143</id>
<content type='text'>
Our home rolled clip-to-cell code was, obviously, not correct.

The original problem was that we couldn't use pixman clipping since we
have multiple threads writing to the same pixman image, and thus there
would be races between the threads setting clipping.

The fix is actually simple - just instantiate one pixman
image (referencing the same backing image data) for each rendering
thread.
</content>
</entry>
<entry>
<title>shm: #ifdef conditional code to measure total size of SHM allocations</title>
<updated>2020-04-18T10:24:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-04-18T10:24:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4f145bed33d1de87993f947cb7fad31130fc868f'/>
<id>urn:sha1:4f145bed33d1de87993f947cb7fad31130fc868f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: memfd seal failures are not fatal errors</title>
<updated>2020-04-03T18:14:53Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-04-03T18:14:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a2081047432c58481592e3e8155017fbbdf6c1da'/>
<id>urn:sha1:a2081047432c58481592e3e8155017fbbdf6c1da</id>
<content type='text'>
</content>
</entry>
<entry>
<title>conf: max-shm-pool-size-mb=0 now disables SHM scrolling</title>
<updated>2020-03-26T17:04:30Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-26T17:04:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c4aaba6299b092cd8221fb6e8c301fe5bfd602a4'/>
<id>urn:sha1:c4aaba6299b092cd8221fb6e8c301fe5bfd602a4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: make max pool size user configurable (via a 'tweak' setting)</title>
<updated>2020-03-25T19:48:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T19:48:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0baa249d8b59007913dbf7db8aa8d94e6c2b9d44'/>
<id>urn:sha1:0baa249d8b59007913dbf7db8aa8d94e6c2b9d44</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: handle ftruncate failure</title>
<updated>2020-03-25T17:32:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:32:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e9f1638750db342fbf26fc9477a970ab2e3e439d'/>
<id>urn:sha1:e9f1638750db342fbf26fc9477a970ab2e3e439d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: seal the memfd</title>
<updated>2020-03-25T17:30:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:30:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=dc42cc1d195a16683c45fc87eb2dc333087a90da'/>
<id>urn:sha1:dc42cc1d195a16683c45fc87eb2dc333087a90da</id>
<content type='text'>
This both prevents accidental resizing of the memfd, and allows the
Wayland server to optimze reads from the buffer - it no longer has to
setup SIGBUS handlers.
</content>
</entry>
<entry>
<title>shm: scroll: keep shm pool around, and fix its size at max allowed</title>
<updated>2020-03-25T17:26:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:26:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=03319560f5c7c908b1c1d229b3ba53ed1ac6b692'/>
<id>urn:sha1:03319560f5c7c908b1c1d229b3ba53ed1ac6b692</id>
<content type='text'>
This lessens the burden on (primarily) the compositor, since we no
longer tear down and re-create the SHM pool when scrolling.

The SHM pool is setup once, and its size is fixed at the maximum
allowed (512MB for now, 2GB would be possible).

This also allows us to mmap() the memfd once. The exposed raw pointer
is simply an offset from the memfd mmapping.

Note that this means e.g. rouge rendering code will be able to write
outside the buffer.

Finally, only do this if the caller explicitly wants to enable
scrolling. The memfd of other buffers are sized to the requested size.
</content>
</entry>
<entry>
<title>shm: scroll: implement offset wrap-around</title>
<updated>2020-03-24T16:46:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-24T16:46:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c5f1d096c3a2a6cb8fb3dc5cb3efad5782c1d78'/>
<id>urn:sha1:5c5f1d096c3a2a6cb8fb3dc5cb3efad5782c1d78</id>
<content type='text'>
* Impose a maximum memfd size limit. In theory, this can be
  2GB (wl_shm_create_pool() is the limiting factor - its size argument
  is an int32_t). For now, use 256MB.

  This is mainly to reduce the amount of virtual address space used by
  the compositor, which keeps at least one mmapping (of the entire
  memfd) around. One mmapping *per terminal window* that is.

  Given that we have 128TB with 48-bit virtual addresses, we could
  probably bump this to 2GB without any issues. However, 256MB should
  be enough.

  TODO: check how much we typically move the offset when scrolling in
  a fullscreen window on a 4K monitor. 256MB may turn out to be too
  small.

  On 32-bit shm_scroll() is completely disabled. There simply isn't
  enough address space.

* Wrapping is done by moving the offset to "the other end" of the
  memfd, and copying the buffer contents to the new, wrapped offset.

  The "normal" scrolling code then does the actual scrolling. This
  means we'll re-instantiate all objects twice when wrapping.
</content>
</entry>
<entry>
<title>shm: shm_scroll(): initial implementation of reverse scrolling</title>
<updated>2020-03-23T20:14:51Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-23T20:14:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=759fd572e972eea24ccc864b22203b1b71030e0d'/>
<id>urn:sha1:759fd572e972eea24ccc864b22203b1b71030e0d</id>
<content type='text'>
Implemented by truncating the file size and moving the offset
backwards. This means we can only reverse scroll when we've previously
scrolled forward.

TODO: figure out if we can somehow do fast reverse scrolling even
though offset is 0 (or well, less than required for scrolling).
</content>
</entry>
<entry>
<title>shm: scroll: move top/bottom region handling from renderer into shm</title>
<updated>2020-03-23T19:45:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-23T19:45:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0de3701984ff3b09a804d8369dafc3cd5baefdcc'/>
<id>urn:sha1:0de3701984ff3b09a804d8369dafc3cd5baefdcc</id>
<content type='text'>
This allows us to restore the regions without copying the contents to
temporary memory.
</content>
</entry>
<entry>
<title>shm: add shm_can_scroll()</title>
<updated>2020-03-23T18:31:05Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-23T18:31:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5ffee087481ddf3ad6e3b8e74c6acd3f0d736d82'/>
<id>urn:sha1:5ffee087481ddf3ad6e3b8e74c6acd3f0d736d82</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: print performance warning when FALLOC_FL_PUNCH_HOLE isn't supported</title>
<updated>2020-03-22T20:05:05Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-22T20:04:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=795b0e7ea1cc7098fcbb76858014ffccffbf8624'/>
<id>urn:sha1:795b0e7ea1cc7098fcbb76858014ffccffbf8624</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: verify the system supports FALLOC_FL_PUNCH_HOLE</title>
<updated>2020-03-22T20:05:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-22T19:36:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7404ace40c1b54db14a95f3f64b9f92104e8024a'/>
<id>urn:sha1:7404ace40c1b54db14a95f3f64b9f92104e8024a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: scroll: no need to instantiate a new buffer when ftruncate() fails</title>
<updated>2020-03-22T19:34:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-22T19:32:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3b9be09b065d50cc0d698faf6a855627b5cf86cc'/>
<id>urn:sha1:3b9be09b065d50cc0d698faf6a855627b5cf86cc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: new function, shm_scroll()</title>
<updated>2020-03-22T19:06:44Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-22T19:06:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1224807f503cf6aaef33388af682f754dcbbc3df'/>
<id>urn:sha1:1224807f503cf6aaef33388af682f754dcbbc3df</id>
<content type='text'>
This function "scrolls" the buffer by the specified number of (pixel)
rows.

The idea is move the image offset by re-sizing the underlying memfd
object. I.e. to scroll forward, increase the size of the memfd file,
and move the pixman image offset forward (and the Wayland SHM buffer
as well).

Only increasing the file size would, obviously, cause the memfd file
to grow indefinitely. To deal with this, we "punch" a whole from the
beginning of the file to the new offset. This frees the associated
memory.

Thus, while we have a memfd file whose size is (as seen by
e.g. fstat()) is ever growing, the actual file size is always the
original buffer size.

Some notes:

* FALLOC_FL_PUNCH_HOLE can be quite slow when the number of used pages
  to drop is large.

* all normal fallocate() usages have been replaced with ftruncate(),
  as this is *much* faster. fallocate() guarantees subsequent writes
  wont fail. I.e. it actually reserves (disk) space. While it doesn't
  allocate on-disk blocks for on-disk files, it *does* zero-initialize
  the in-memory blocks. And this is slow. ftruncate() doesn't do this.

TODO: implement reverse scrolling (i.e. a negative row count).
</content>
</entry>
<entry>
<title>shm: log size of purged buffer</title>
<updated>2020-03-18T15:41:38Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-18T15:41:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7b610e018b3dcfd21fac243d2b9d5bec3227da5c'/>
<id>urn:sha1:7b610e018b3dcfd21fac243d2b9d5bec3227da5c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: we don't really handle SHM failures, so just abort()</title>
<updated>2020-03-10T17:06:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-10T17:02:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8a6cfb738b8c21b79d8f6497f8147e0085e26c7f'/>
<id>urn:sha1:8a6cfb738b8c21b79d8f6497f8147e0085e26c7f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: mmap returns MAP_FAILED, so use that as guard value</title>
<updated>2020-03-10T17:06:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-10T17:01:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=cf5da1039ffb53a9ae1d789a78835b9573a95d4b'/>
<id>urn:sha1:cf5da1039ffb53a9ae1d789a78835b9573a95d4b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: set pool_fd=1 after closing it, to avoid double-closing on error</title>
<updated>2020-03-10T17:06:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-10T17:01:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=867dc836abb8904f324f5904d8714012fab33bf3'/>
<id>urn:sha1:867dc836abb8904f324f5904d8714012fab33bf3</id>
<content type='text'>
</content>
</entry>
</feed>
