Skip to content

Commit 9550562

Browse files
nigrosimoneaduh95
authored andcommitted
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> PR-URL: #66344 Refs: #66316 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 656d78d commit 9550562

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
@@ -206,7 +206,6 @@ bool AsyncHooks::pop_async_context(double async_id) {
206206
} else {
207207
native_execution_async_resources_.resize(offset);
208208
}
209-
native_execution_async_resources_.shrink_to_fit();
210209
}
211210

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

0 commit comments

Comments
 (0)