mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
feat: build a zone's 3D data on worker threads
Opening a zone the first time built its terrain, scene objects and manifests and ran ImageMagick on the web thread, stalling the dashboard for seconds. - Workers: the shared pool plus Workers::Reply (answer at once when built, else from a worker via Web::Defer). - terrain_chunks/terrain_layers/scene/paths/scenery/flairs (world3d, property and showcase routes) and terrain textures go through it; results are built once in OnceCaches, the .raw is read once per zone for chunks, layers and flairs, deflated bodies are cached thread-safely. - ImageMagick conversions are deduplicated and written under a temporary name. - Workers don't query the CDClient, read settings or call mongoose: ZoneTable, render components, flairs, object names, LOT kinds and terrain texture names are read at startup; client_location is read once; base64 is plain C++. - Logger writes one line at a time (mutex; localtime's buffer is shared). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,11 @@
|
||||
#include "ModeratorHelper.h"
|
||||
#include "LiveWorld.h"
|
||||
#include "Scenery.h"
|
||||
#include "Workers.h"
|
||||
#include "ReportRoutes.h"
|
||||
#include "WorldView.h"
|
||||
#include "ClientAssets.h"
|
||||
#include "DashboardRoutes.h"
|
||||
#include "LiveEventRoutes.h"
|
||||
#include "ChallengeRoutes.h"
|
||||
#include "Inspector.h"
|
||||
@@ -411,6 +416,19 @@ int main(int argc, char** argv) {
|
||||
);
|
||||
Game::server = g_Server;
|
||||
|
||||
// What the worker threads read from the CDClient and the settings, read now on this thread: workers never query
|
||||
// the CDClient, read settings or touch the network (RakNet and mongoose are the main thread's)
|
||||
{
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
ClientAssets::Preload();
|
||||
PreloadZoneData();
|
||||
Scenery::Preload();
|
||||
WorldView::Preload();
|
||||
ZoneNames();
|
||||
LOG("Read the client data for the 3D views in %lld ms", static_cast<long long>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count()));
|
||||
}
|
||||
Workers::Start();
|
||||
|
||||
// Initialize web server
|
||||
if (!Game::web.Startup(ourIP, ourPort)) {
|
||||
LOG("Failed to start web server on %s:%d", ourIP.c_str(), ourPort);
|
||||
@@ -570,8 +588,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
}
|
||||
|
||||
// Cleanup: the conversion threads first (they answer deferred requests), then the web server's connections
|
||||
Scenery::Shutdown();
|
||||
// Cleanup: the worker threads first (they answer deferred requests), then the web server's connections
|
||||
Workers::Stop();
|
||||
Game::web.Shutdown();
|
||||
Inspector::Shutdown();
|
||||
EmailService::Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user