1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add support for Tracy profiler (#15113)

This commit is contained in:
DS 2024-09-15 13:47:45 +02:00 committed by GitHub
parent 6f23de41fb
commit 4aec4fbe6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 379 additions and 4 deletions

View file

@ -75,6 +75,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gameparams.h"
#include "particles.h"
#include "gettext.h"
#include "util/tracy_wrapper.h"
class ClientNotFoundException : public BaseException
{
@ -101,6 +102,8 @@ private:
void *ServerThread::run()
{
ZoneScoped;
BEGIN_DEBUG_EXCEPTION_HANDLER
/*
@ -110,6 +113,7 @@ void *ServerThread::run()
* server-step frequency. Receive() is used for waiting between the steps.
*/
auto framemarker = FrameMarker("ServerThread::run()-frame").started();
try {
m_server->AsyncRunStep(0.0f, true);
} catch (con::ConnectionBindFailed &e) {
@ -119,10 +123,12 @@ void *ServerThread::run()
} catch (ModError &e) {
m_server->setAsyncFatalError(e.what());
}
framemarker.end();
float dtime = 0.0f;
while (!stopRequested()) {
framemarker.start();
ScopeProfiler spm(g_profiler, "Server::RunStep() (max)", SPT_MAX);
u64 t0 = porting::getTimeUs();
@ -149,6 +155,7 @@ void *ServerThread::run()
}
dtime = 1e-6f * (porting::getTimeUs() - t0);
framemarker.end();
}
END_DEBUG_EXCEPTION_HANDLER
@ -607,6 +614,9 @@ void Server::step()
void Server::AsyncRunStep(float dtime, bool initial_step)
{
ZoneScoped;
auto framemarker = FrameMarker("Server::AsyncRunStep()-frame").started();
{
// Send blocks to clients
SendBlocks(dtime);
@ -1055,6 +1065,9 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
void Server::Receive(float timeout)
{
ZoneScoped;
auto framemarker = FrameMarker("Server::Receive()-frame").started();
const u64 t0 = porting::getTimeUs();
const float timeout_us = timeout * 1e6f;
auto remaining_time_us = [&]() -> float {