Skip to content

Commit 1c112c2

Browse files
graphicsManfacebook-github-bot
authored andcommitted
Change dispenso default for Linux to event-based wakeup
Summary: For software which has infrequent use of the thread pool, this results in an order of magnitude less system resources being used due to strongly reduced polling. In some benchmarks, it can lead to a small percentage reduction in throughput. Differential Revision: D63671846 fbshipit-source-id: 752d639fa6199094992fc4382c89ad3a1d77219e
1 parent 1f044c3 commit 1c112c2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

dispenso/thread_pool.h

+13-10
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,32 @@
3131

3232
namespace dispenso {
3333

34+
#if !defined(DISPENSO_WAKEUP_ENABLE)
35+
#if defined(_WIN32) || defined(__linux__)
36+
#define DISPENSO_WAKEUP_ENABLE 1
37+
#else
38+
// TODO(bbudge): For now, only enable Linux and Windows. On Mac still need to figure out how to
39+
// wake more quickly (see e.g.
40+
// https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html)
41+
#define DISPENSO_WAKEUP_ENABLE 0
42+
#endif // Linux or Windows
43+
#endif // DISPENSO_WAKEUP_ENABLE
44+
3445
#if !defined(DISPENSO_POLL_PERIOD_US)
3546
#if defined(_WIN32)
3647
#define DISPENSO_POLL_PERIOD_US 1000
3748
#else
38-
#if !defined(DISPENSO_WAKEUP_ENABLE)
49+
#if !(DISPENSO_WAKEUP_ENABLE)
3950
#define DISPENSO_POLL_PERIOD_US 200
4051
#else
41-
#define DISPENSO_POLL_PERIOD_US 8000
52+
#define DISPENSO_POLL_PERIOD_US (1 << 15) // Determined empirically good on dual Xeon Linux
4253
#endif // DISPENSO_WAKEUP_ENABLE
4354
#endif // PLATFORM
4455
#endif // DISPENSO_POLL_PERIOD_US
4556

4657
constexpr uint32_t kDefaultSleepLenUs = DISPENSO_POLL_PERIOD_US;
4758

48-
#if defined(DISPENSO_WAKEUP_ENABLE)
4959
constexpr bool kDefaultWakeupEnable = DISPENSO_WAKEUP_ENABLE;
50-
#else
51-
#if defined(__WIN32)
52-
constexpr bool kDefaultWakeupEnable = true;
53-
#else
54-
constexpr bool kDefaultWakeupEnable = false;
55-
#endif // PLATFORM
56-
#endif // DISPENSO_WAKEUP_ENABLE
5760

5861
/**
5962
* A simple tag specifier that can be fed to TaskSets and

0 commit comments

Comments
 (0)