Commit 78e4678
authored
feat(blst): use external buffers for blst operations (#358)
Depends on ChainSafe/zapi#30 (we need to release zapi and update the
dep)
This is one of possible likely causes for increased GC pressure on
experiments to swap out blst-ts for lodestar-z/bls, as observed on feat2
and feat3 deployments in [this
PR](ChainSafe/lodestar#9342).
With external array buffers, V8 is only aware of the pointer to the
backing memory, instead of having to track both the pointer and the
backing memory. This means that during marking phase the GC does not
have to walk the backing memory to mark it as 'live' - the frequency of
the GC firing off is still the same, but each cycle does less work.
This of course comes with a tradeoff, we need a
**finalizer** to let V8 know how much external memory is in native heap
so that the GC tells the native impl to free the useless memory.
Though, regardless of the effect, we should still probably do this
anyway, since [napi-rs does the
same](https://github.com/napi-rs/napi-rs/blob/159395b365c583a6642ad481edc5708d9f36a24b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs#L175),
and only defaults to V8 managed array buffers if it is disallowed (like
in Electron).1 parent c52af09 commit 78e4678
2 files changed
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments