uv: fix performance issue

unix implementation of uv_async_t has been wasting cpu cycles for nothing since 1.29.0 release
implement efficient callback scheduling for linux
This commit is contained in:
cohcho 2020-10-12 04:09:09 +00:00
parent f85efd163c
commit 65fa1d9bf3
5 changed files with 110 additions and 0 deletions

27
src/base/io/Async.h Normal file
View file

@ -0,0 +1,27 @@
#pragma once
#include <uv.h>
// since 2019.05.16, Version 1.29.0 (Stable)
#if (UV_VERSION_MAJOR >= 1) && (UV_VERSION_MINOR >= 29) && defined(__linux__)
#define XMRIG_UV_PERFORMANCE_BUG
namespace xmrig {
struct uv_async_t: uv_poll_t
{
typedef void (*uv_async_cb)(uv_async_t* handle);
~uv_async_t();
int m_fd = -1;
uv_async_cb m_cb = nullptr;
};
using uv_async_cb = uv_async_t::uv_async_cb;
extern int uv_async_init(uv_loop_t *loop, uv_async_t *async, uv_async_cb cb);
extern int uv_async_send(uv_async_t *async);
} // namespace xmrig
#endif