stream: reuse unexposed managed read buffers · nodejs/node@39318a1 · GitHub
Skip to content

Commit 39318a1

Browse files
committed
stream: reuse unexposed managed read buffers
Signed-off-by: GetThatCookie <NimmenKeks@gmx.de>
1 parent bb58fcd commit 39318a1

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎src/env.cc‎

Lines changed: 17 additions & 4 deletions

‎src/env.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,9 @@ class Environment final : public MemoryRetainer {
10411041

10421042
uv_buf_t allocate_managed_buffer(const size_t suggested_size);
10431043
std::unique_ptr<v8::BackingStore> release_managed_buffer(const uv_buf_t& buf);
1044+
// Only buffers that were not exposed externally may be recycled.
1045+
void recycle_managed_buffer(
1046+
std::unique_ptr<v8::BackingStore> backing_store);
10441047

10451048
void AddUnmanagedFd(int fd);
10461049
void RemoveUnmanagedFd(int fd);
@@ -1257,6 +1260,9 @@ class Environment final : public MemoryRetainer {
12571260
std::unordered_map<char*, std::unique_ptr<v8::BackingStore>>
12581261
released_allocated_buffers_;
12591262

1263+
// Retains at most one unexposed read buffer for reuse.
1264+
std::unique_ptr<v8::BackingStore> managed_buffer_cache_;
1265+
12601266
v8::CpuProfiler* cpu_profiler_ = nullptr;
12611267
std::vector<v8::ProfilerId> pending_profiles_;
12621268
};

‎src/stream_base.cc‎

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)