Skip to content

Commit

Permalink
Rearrange the order of variables in ThreadLocalStorage for reduced pa…
Browse files Browse the repository at this point in the history
…dding
  • Loading branch information
RichieSams committed Jan 17, 2021
1 parent c50c82f commit 8af2879
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions include/ftl/task_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ class TaskScheduler {
}

public:
// NOTE: The order of these variables may seem odd / jumbled. However, it it to optimize the padding required

/* The queue of high priority waiting tasks. This also contains the ready waiting fibers, which are differentiated by the Task function == ReadyFiberDummyTask */
WaitFreeQueue<TaskBundle> HiPriTaskQueue;
/* The queue of high priority waiting tasks */
WaitFreeQueue<TaskBundle> LoPriTaskQueue;

std::atomic<bool> *OldFiberStoredFlag{nullptr};

/* The queue of ready waiting Fibers that were pinned to this thread */
std::vector<ReadyFiberBundle *> PinnedReadyFibers;

/**
* The current fiber implementation requires that fibers created from threads finish on the same thread where
* they started
Expand All @@ -164,27 +176,22 @@ class TaskScheduler {
* safely clean up.
*/
Fiber ThreadFiber;

/* Lock protecting access to PinnedReadyFibers */
std::mutex PinnedReadyFibersLock;

/* The index of the current fiber in m_fibers */
unsigned CurrentFiberIndex;
/* The index of the previously executed fiber in m_fibers */
unsigned OldFiberIndex;
/* Where OldFiber should be stored when we call CleanUpPoolAndWaiting() */
FiberDestination OldFiberDestination{FiberDestination::None};
/* The queue of high priority waiting tasks. This also contains the ready waiting fibers, which are differentiated by the Task function == ReadyFiberDummyTask */
WaitFreeQueue<TaskBundle> HiPriTaskQueue;

/* The last high priority queue that we successfully stole from. This is an offset index from the current thread index */
unsigned HiPriLastSuccessfulSteal{1};
/* The queue of high priority waiting tasks */
WaitFreeQueue<TaskBundle> LoPriTaskQueue;
/* The last high priority queue that we successfully stole from. This is an offset index from the current thread index */
/* The last low priority queue that we successfully stole from. This is an offset index from the current thread index */
unsigned LoPriLastSuccessfulSteal{1};

std::atomic<bool> *OldFiberStoredFlag{nullptr};

/* The queue of ready waiting Fibers that were pinned to this thread */
std::vector<ReadyFiberBundle *> PinnedReadyFibers;
std::mutex PinnedReadyFibersLock;

unsigned FailedQueuePopAttempts{0};
};
/**
Expand Down

0 comments on commit 8af2879

Please sign in to comment.