aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-06-07 13:25:30 +0200
committerStefan Boberg <[email protected]>2023-06-07 13:25:30 +0200
commit165d5472afe3c3d13c8c855701c00180507ebe54 (patch)
treeb32d3f589abd12f487b800632882140e3e4a3538 /src
parent0.2.13-pre1 (diff)
downloadzen-165d5472afe3c3d13c8c855701c00180507ebe54.tar.xz
zen-165d5472afe3c3d13c8c855701c00180507ebe54.zip
added thread names to timer, upstream monitor
also altered http-asio thread naming scheme
Diffstat (limited to 'src')
-rw-r--r--src/zenhttp/httpasio.cpp11
-rw-r--r--src/zenserver/upstream/upstreamcache.cpp2
-rw-r--r--src/zenserver/zenserver.cpp8
3 files changed, 19 insertions, 2 deletions
diff --git a/src/zenhttp/httpasio.cpp b/src/zenhttp/httpasio.cpp
index b76f3d2e3..8ac36c7f3 100644
--- a/src/zenhttp/httpasio.cpp
+++ b/src/zenhttp/httpasio.cpp
@@ -1250,10 +1250,19 @@ HttpAsioServerImpl::Start(uint16_t Port, int ThreadCount)
m_Acceptor.reset(new asio_http::HttpAcceptor(*this, m_IoService, Port));
m_Acceptor->Start();
+ // This should consist of a set of minimum threads and grow on demand to
+ // meet concurrency needs? Right now we end up allocating a large number
+ // of threads even if we never end up using all of them, which seems
+ // wasteful. It's also not clear how the demand for concurrency should
+ // be balanced with the engine side - ideally we'd have some kind of
+ // global scheduling to prevent one side from preventing the other side
+ // from making progress. Or at the very least, thread priorities should
+ // be considered.
+
for (int i = 0; i < ThreadCount; ++i)
{
m_ThreadPool.emplace_back([this, Index = i + 1] {
- SetCurrentThreadName(fmt::format("asio worker {}", Index));
+ SetCurrentThreadName(fmt::format("asio_io_{}", Index));
try
{
diff --git a/src/zenserver/upstream/upstreamcache.cpp b/src/zenserver/upstream/upstreamcache.cpp
index 9f6a0abc4..01ba626bd 100644
--- a/src/zenserver/upstream/upstreamcache.cpp
+++ b/src/zenserver/upstream/upstreamcache.cpp
@@ -1990,6 +1990,8 @@ private:
void MonitorEndpoints()
{
+ SetCurrentThreadName("upstream_monitor");
+
for (;;)
{
{
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 76aa78f37..363f168fe 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -536,7 +536,10 @@ public:
{
if (!m_IoRunner.joinable())
{
- m_IoRunner = std::thread{[this] { m_IoContext.run(); }};
+ m_IoRunner = std::thread{[this] {
+ zen::SetCurrentThreadName("timer_io");
+ m_IoContext.run();
+ }};
}
}
@@ -1255,7 +1258,10 @@ ZenEntryPoint::Run()
// Monitor shutdown signals
ShutdownThread.reset(new std::thread{[&] {
+ zen::SetCurrentThreadName("shutdown_monitor");
+
ZEN_INFO("shutdown monitor thread waiting for shutdown signal '{}'", ShutdownEventName);
+
if (ShutdownEvent->Wait())
{
if (!IsApplicationExitRequested())