gbranden pushed a commit to branch master
in repository groff.
commit d82a7ccec1f469d362d1159a394b8d5ca0e5251a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Mar 19 08:16:10 2026 -0500
ChangeLog: Clarify old entry.
---
ChangeLog | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 30c488d30..d467b8ae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -75,31 +75,34 @@
2026-03-17 G. Branden Robinson <[email protected]>
[grotty]: Revise dynamic memory allocation strategy. The
- `tty_printer` class maintains a member variables `lines` which
- is a pointer to a pointer to type `tty_glyph`, implementing a
- {de facto} rectangular array of character cells. The strategy
- that grotty has used to date proved to perform badly with the
- new approach to continuous rendering used by groff's man(7) and
- mdoc(7) packages in version 1.24.0. If the initial allocation
- of 66 lines (rows) of character cells was insufficient because
- the input extended the page length, it grew the allocation (and
- performed a memcpy(3)) only as much as required to house the
- vertical drawing position, plus one line). For a famously
+ `tty_printer` class maintains a member variable `lines`, a
+ pointer to a pointer to type `tty_glyph`, which it uses as a
+ reference to a dynamically allocated rectangular array of
+ character cells. The size of this array is not fixed; `pl`
+ requests in an input document can grow or shrink the page
+ length. The resizing strategy that grotty has used to date
+ proved to perform badly with the new approach to continuous
+ rendering used by groff's man(7) and mdoc(7) packages in version
+ 1.24.0. If the initial allocation of 66 lines (rows) of
+ character cells was insufficient because the input extended the
+ page length, it grew the allocation (and performed a memcpy(3)
+ of its existing contents) by only as much as required to house
+ the vertical drawing position, plus one line. For a famously
lengthy man page like bash(1), this meant many repeated trips
- through new/memcpy()/delete operations, giving the language
+ through new/memcpy()/delete sequences, giving the language
runtime allocator a lot of work to do. In an extreme case
{formatting 64 copies of bash(1) in sequence}, this led to long
runtimes with two-thirds of program time spent in the kernel.
- The new approach is to double the allocation every time it is
- exceeded, but also to free that allocation at the end of every
- page. When continuously rendering, there will only ever be one
- page anyway, but this tactic is more considerate for the
- {admittedly niche} case of paginated documents that vary the
+ The new strategy is to double the allocation size every time it
+ is exceeded, but also to free any resized allocation at the end
+ of every page. When continuously rendering, there will only
+ ever be one page anyway, but this tactic is more considerate for
+ the {admittedly niche} case of paginated documents that vary the
page length frequently--which is the approach that groff 1.23.0
and earlier took to continuous rendering, and that other macro
- packages or documents might still (but beware of the sort of
- problem observed in Savannah #65189).
+ packages or documents might still. (tbl(1) users should beware
+ of the sort of problem observed in Savannah #65189.)
* src/devices/grotty/tty.cpp: Define new global constant
integer, `default_lines_per_page`, obviating a local literal in
@@ -107,12 +110,12 @@
(class tty_printer): Drop empty body from `begin_page()`
declaration.
(tty_printer::tty_printer): Replace open-coded initial
- allocation storage backing `lines` member variable with call to
+ storage allocation backing `lines` member variable with call to
`begin_page()`.
(tty_printer::~tty_printer): Stop freeing the storage backing
`lines` here. Instead...
- (tty_printer::end_page): ...do it here, if its size grew past
- beyond default initial allocation.
+ (tty_printer::end_page): ...do it here, if its size grew beyond
+ the default initial allocation.
(tty_printer::add_char): Apply the new reallocation strategy.
Use memset(3) to zero out the new storage before memcpy(3)-ing
the previous contents into (part of) it, eliminating a `for`
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit