Skip to content

Commit

Permalink
Allow any number of build threads
Browse files Browse the repository at this point in the history
  • Loading branch information
deplinenoise committed Aug 4, 2024
1 parent c54852f commit f3bb549
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/BuildQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,10 @@ namespace t2
queue->m_ExpensiveWaitCount = 0;
queue->m_ExpensiveWaitList = HeapAllocateArray<NodeState*>(heap, capacity);

CHECK(queue->m_Queue);

if (queue->m_Config.m_ThreadCount > kMaxBuildThreads)
{
Log(kWarning, "too many build threads (%d) - clamping to %d",
queue->m_Config.m_ThreadCount, kMaxBuildThreads);
queue->m_Threads = HeapAllocateArrayZeroed<ThreadId>(config->m_Heap, config->m_ThreadCount);
queue->m_ThreadState = HeapAllocateArrayZeroed<ThreadState>(config->m_Heap, config->m_ThreadCount);

queue->m_Config.m_ThreadCount = kMaxBuildThreads;
}
CHECK(queue->m_Queue);

Log(kDebug, "build queue initialized; ring buffer capacity = %u", queue->m_QueueCapacity);

Expand Down Expand Up @@ -797,6 +792,9 @@ namespace t2
CondDestroy(&queue->m_WorkAvailable);
MutexDestroy(&queue->m_Lock);

HeapFree(config->m_Heap, queue->m_ThreadState);
HeapFree(config->m_Heap, queue->m_Threads);

// Unblock all signals on the main thread.
SignalHandlerSetCondition(nullptr);
SignalBlockThread(false);
Expand Down
9 changes: 2 additions & 7 deletions src/BuildQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ namespace t2
struct StatCache;
struct DigestCache;

enum
{
kMaxBuildThreads = 64
};

struct BuildQueueConfig
{
enum
Expand Down Expand Up @@ -73,8 +68,8 @@ namespace t2
int32_t m_PendingNodeCount;
int32_t m_FailedNodeCount;
int32_t m_CurrentPassIndex;
ThreadId m_Threads[kMaxBuildThreads];
ThreadState m_ThreadState[kMaxBuildThreads];
ThreadId *m_Threads;
ThreadState *m_ThreadState;
int32_t m_ExpensiveRunning;
int32_t m_ExpensiveWaitCount;
NodeState **m_ExpensiveWaitList;
Expand Down

0 comments on commit f3bb549

Please sign in to comment.