Skip to content

Commit a3a1b3c

Browse files
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

File tree

‎src/env.cc‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ bool AsyncHooks::pop_async_context(double async_id) {
196196
}
197197
#endif
198198
native_execution_async_resources_.resize(offset);
199-
native_execution_async_resources_.shrink_to_fit();
200199
}
201200

202201
if (js_execution_async_resources()->Length() > offset) [[unlikely]] {

0 commit comments

Comments
 (0)