cameron314 / cameron314/concurrentqueue
Pre-allocation of producers
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.5k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
As far as I understood, the constructor:
ConcurrentQueue(size_t minCapacity, size_t maxExplicitProducers, size_t maxImplicitProducers)
uses the maxExplicitProducers and maxImplicitProducers to set the initial number of blocks. However, it does not preallocate producers (via add_producer). This means that try_enqueue can still malloc a producer when it is called.
Could the constructor mentioned above also include the following snippet in its body to minimise the chance of malloc when using try_enqueue?
for(size_t i = 0; i != maxImplicitProducers; ++i) {
auto* p = add_producer(create<ImplicitProducer>(this));
p->inactive.store(true, std::memory_order_relaxed);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ConcurrentQueue(size_t minCapacity, size_t maxExplicitProducers, size_t maxImplicitProducers) constructor and trace add_producer, create, and try_enqueue. Check how producer allocation currently occurs and whether inactive preallocated producers are safe for this queue lifecycle. Done means the constructor preallocates the requested implicit producers and try_enqueue no longer needs to allocate one in the described case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100