Commit a3a1b3c
committed
src: do not shrink async resources on every pop
AsyncHooks::pop_async_context() calls shrink_to_fit() on
native_execution_async_resources_ after every pop. With the MSVC and
libc++ standard libraries, shrink_to_fit() on an empty std::deque frees
its storage, so every top-level callback scope allocates it again on
push and frees it on pop. libstdc++ does nothing here.
A program with the same pattern, a std::deque of the same variant going
from 0 to 1 to 0 elements, takes 136-147 ns per callback on Windows
with MSVC, and 6 ns without shrink_to_fit(). The async_ids_stack_ next
to it never shrinks either.
Refs: nodejs/performance#24
Signed-off-by: Nigro Simone <nigro.simone@gmail.com>1 parent 66f26d3 commit a3a1b3c
1 file changed
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | 199 | | |
201 | 200 | | |
202 | 201 | | |
| |||
0 commit comments