ccan/tal: always include a length field.
The current semantics of tal_count() / tal_bytelen() are to return 0
for anything not allocated using tal_arr*. This is because we tried
to save a native-length word in the header, but produces an awkward
API.
(To make it worse, defining CCAN_TAL_DEBUG turns length to always on,
and we enable that for c-lightning developer mode, which hides bugs!).
However, for c-lightning, just over half of allocations want a length:
these use 3 words each, so we're actually worse off overall.
The answer is to always have a length field in the header. This also
simplfies the tal code.
samba-allocs stats before:
Tal time: 1237102-1305755(1.251e+06+/-2.1e+04)ns
Tal_free time: 1346871-1514514(1.37844e+06+/-5.2e+04)ns
After:
Tal time: 1115180-1180633(1.1351e+06+/-2.1e+04)ns
Tal_free time: 1334381-1465933(1.39148e+06+/-4.7e+04)ns
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing
Please register or sign in to comment