about summary refs log tree commit diff
path: root/users/sterni/nix/utf8/tests/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-11-22T21·06+0100
committersterni <sternenseemann@systemli.org>2021-11-23T13·22+0100
commit8615322bc81dfe106aa158b95567300372ea469d (patch)
tree83fe1e4eebe2df260183e4c298738b07a98537d5 /users/sterni/nix/utf8/tests/default.nix
parenta2be05faa4043c225581090846c52718812fac8f (diff)
refactor(sterni/nix/utf8): use genericClosure for decoding iteration r/3085
builtins.genericClosure is a quite powerful (and undocumented) Nix
primop: It repeatedly applies a function to values it produces and
collects them into a list. Additionally individual results can be
identified via a key attribute.

Since genericClosure only ever creates a single list value internally,
we can eliminate a huge performance bottleneck when building a list in a
recursive algorithm: list concatenation. Because Nix needs to copy the
entire chunk of memory used internally to represent the list, building
big lists one element at a time grinds Nix to a halt.

After rewriting decode using genericClosure decoding the LaTeX source
of my 20 page term paper now takes 2s instead of 14min.

Change-Id: I33847e4e7dd95d7f4d78ac83eb0d74a9867bfe80
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions