Although https://github.com/status-im/nim-chronos/pull/418 was ultimately not merged, it contains an idea to improve performance in general: instead of allocating a separate var result that gets injected, it instead injects a template result = fut.internalValue which means we use the in-flight future as temporary storage for results instead of a local variable thus saving memory, zero:es and copies.
The technique is interesting but needs to be tested against https://github.com/nim-lang/Nim/issues/22605 of which it may run afoul (along with other correctness / observability issues).
Although https://github.com/status-im/nim-chronos/pull/418 was ultimately not merged, it contains an idea to improve performance in general: instead of allocating a separate
var result
that gets injected, it instead injects atemplate result = fut.internalValue
which means we use the in-flight future as temporary storage for results instead of a local variable thus saving memory, zero:es and copies.The technique is interesting but needs to be tested against https://github.com/nim-lang/Nim/issues/22605 of which it may run afoul (along with other correctness / observability issues).