diff options
| author | Stefan Boberg <[email protected]> | 2026-04-20 21:22:01 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-20 21:22:01 +0200 |
| commit | 29736c4fed154233a8adbf93b29995c8e0b3ea78 (patch) | |
| tree | 191dc746745e12904fff58beb45ed89aff1601fb /src/zencore/workthreadpool.cpp | |
| parent | s3 dehydration touch cas (#977) (diff) | |
| download | archived-zen-29736c4fed154233a8adbf93b29995c8e0b3ea78.tar.xz archived-zen-29736c4fed154233a8adbf93b29995c8e0b3ea78.zip | |
Use eastl::deque for queues with many small elements (#991)
Switch several deque-based queues from `std::deque` to `eastl::deque` to reduce per-element heap allocation overhead. MSVC's `std::deque` allocates one node per element for anything larger than ~16 bytes; `eastl::deque` groups 4, 8, or 32 elements per block depending on element size.
Converted call sites:
- `BlockingQueue` and `WorkerThreadPool` (generic — downstream callers benefit automatically)
- Session log entry buffer (~10k-entry ring of large log records — 4 per block vs 1)
- Job queue (`Ref<Job>` — 32 per block vs 2)
- RPC recording request queue (large `QueuedRequest` struct — 4 per block vs 1)
- StatsD client message queues (~32-byte buffers — 8 per block vs 1)
Diffstat (limited to 'src/zencore/workthreadpool.cpp')
| -rw-r--r-- | src/zencore/workthreadpool.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/zencore/workthreadpool.cpp b/src/zencore/workthreadpool.cpp index 1cb338c66..fb7edb2bd 100644 --- a/src/zencore/workthreadpool.cpp +++ b/src/zencore/workthreadpool.cpp @@ -4,6 +4,10 @@ #include <zencore/blockingqueue.h> #include <zencore/except.h> + +ZEN_THIRD_PARTY_INCLUDES_START +#include <EASTL/deque.h> +ZEN_THIRD_PARTY_INCLUDES_END #include <zencore/logging.h> #include <zencore/scopeguard.h> #include <zencore/string.h> @@ -56,8 +60,8 @@ struct WorkerThreadPool::Impl std::atomic<size_t> m_WorkerThreadCounter{0}; std::atomic<int> m_FreeWorkerCount{0}; - mutable RwLock m_QueueLock; - std::deque<Ref<IWork>> m_WorkQueue; + mutable RwLock m_QueueLock; + eastl::deque<Ref<IWork>> m_WorkQueue; Impl(int InThreadCount, std::string_view WorkerThreadBaseName) : m_ThreadCount(InThreadCount) |