Skip to content

Commit

Permalink
Merge pull request #3217 from cloudflare/jphillips/empty-writable-str…
Browse files Browse the repository at this point in the history
…eam-memory-optimization

Use std::list for WritableImpl::writeRequests.
  • Loading branch information
jp4a50 authored Dec 6, 2024
2 parents 60115fd + 9867fe2 commit 4a5f272
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/workerd/api/streams/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <workerd/jsg/jsg.h>
#include <workerd/util/weak-refs.h>

#include <list>

namespace workerd::api {

// =======================================================================================
Expand Down Expand Up @@ -367,7 +369,9 @@ class WritableImpl {
bool backpressure = false;
size_t highWaterMark = 1;

std::deque<WriteRequest> writeRequests;
// `writeRequests` is often going to be empty in common usage patterns, in which case std::list
// is more memory efficient than a std::deque, for example.
std::list<WriteRequest> writeRequests;
size_t amountBuffered = 0;
bool warnAboutExcessiveBackpressure = true;
size_t excessiveBackpressureWarningCount = 0;
Expand Down

0 comments on commit 4a5f272

Please sign in to comment.