Skip to content

Commit 9acb68b

Browse files
cosmo0920edsiper
authored andcommitted
lib: monkey: core event kqueue: don't use NOTE_SECONDS on macOS
When using NOTE_SECONDS side of EV_SET routine on macOS, we got a severe performance degradation on threaded input plugin environment. Instead, we shouldn't use NOTE_SECONDS event filtering flag and specify as milliseconds on macOS. Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 15ae57d commit 9acb68b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/monkey/mk_core/mk_event_kqueue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,14 @@ static inline int _mk_event_timeout_create(struct mk_event_ctx *ctx,
201201
event->_priority_head.next = NULL;
202202
event->_priority_head.prev = NULL;
203203

204-
#ifdef NOTE_SECONDS
204+
#if defined(NOTE_SECONDS) && !defined(__APPLE__)
205205
/* FreeBSD or LINUX_KQUEUE defined */
206206
/* TODO : high resolution interval support. */
207207
EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, sec, event);
208208
#else
209209
/* Other BSD have no NOTE_SECONDS & specify milliseconds */
210+
/* Also, on macOS, NOTE_SECONDS has severe side effect that cause
211+
* performance degradation. */
210212
EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, 0, (sec * 1000) + (nsec / 1000000) , event);
211213
#endif
212214
ret = kevent(ctx->kfd, &ke, 1, NULL, 0, NULL);

0 commit comments

Comments
 (0)