tvl-depot/tvix/eval/src/value
Aspen Smith 6366cee717 feat(tvix/eval): Intern (and leak) small strings, behind a mutex
This is the most naive version of string interning possible - we store a
map from the string itself to the pointer behind a global mutex, and
memoize the allocation of all strings below a threshold length (16
bytes, for now) into that map. This requires leaking /all/ strings,
since it's not easy to know just from the pointer that a string has been
interned - so interning is disabled if string leaking is also disabled.

In the case where we're leaking strings (the default), even the naive
version of this gets us a pretty nice perfomance boost:

hello outpath           time:   [742.54 ms 745.89 ms 749.14 ms]
                        change: [-2.8722% -2.0135% -1.0654%] (p = 0.00 < 0.05)
                        Performance has improved.

However, in the case where we're not leaking strings, we have to keep
track of which strings have and haven't been interned, which makes this
a little worse:

hello outpath           time:   [779.30 ms 792.82 ms 808.74 ms]
                        change: [+2.5258% +4.0884% +5.8931%] (p = 0.00 < 0.05)
                        Performance has regressed.

Hopefully we can close the gap here a bit with some clever
tricks (coming next).

Change-Id: If08cb48ede703c7fe3bdd8d617443f8a561ad09b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12047
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: aspen <root@gws.fyi>
2024-08-08 00:02:36 +00:00
..
attrs fix(tvix/eval): Propagate catchables in NixAttrs::construct 2024-02-09 19:11:09 +00:00
arbitrary.rs feat(tvix/eval): Store string context alongside data 2024-02-21 20:53:04 +00:00
attrs.rs feat(tvix/eval): Store string context alongside data 2024-02-21 20:53:04 +00:00
builtin.rs docs(tvix/eval): fix some broken docstr references 2023-09-22 09:14:33 +00:00
function.rs feat(tvix/eval): track pattern binding names 2024-01-25 11:37:35 +00:00
json.rs feat(tvix/eval): rm NixContext::join, add take_context & IntoIterator 2024-05-23 14:50:38 +00:00
list.rs fix(tvix/eval): Inline List.sort_by, and propagate errors 2024-02-08 22:50:27 +00:00
mod.rs refactor(tvix/eval): Drop LightSpan entirely 2024-07-05 03:53:44 +00:00
path.rs refactor(tvix/eval): factor out all calls to canon_path 2022-10-13 09:07:47 +00:00
string.rs feat(tvix/eval): Intern (and leak) small strings, behind a mutex 2024-08-08 00:02:36 +00:00
thunk.rs feat(tvix/eval): Forbid Hash{Map,Set}, use Fx instead 2024-08-07 12:38:40 +00:00