nim-chronos icon indicating copy to clipboard operation
nim-chronos copied to clipboard

Write to `Future.internalValue` directly in macro-translated code

Open arnetheduck opened this issue 8 months ago • 0 comments

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).

arnetheduck avatar Oct 16 '23 09:10 arnetheduck