1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-13 08:35:20 +02:00

Move malloc_trim invocations to background thread (#14744)

This commit is contained in:
sfan5
2024-06-17 15:59:35 +02:00
committed by GitHub
parent d7f4ce6cff
commit fac9aac821
4 changed files with 30 additions and 11 deletions

View File

@@ -24,18 +24,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h"
#include "map.h"
#include "util/directiontables.h"
#include "porting.h"
static class BlockPlaceholder {
public:
MapNode data[MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE];
// Data placeholder used for copying from non-existent blocks
static struct BlockPlaceholder {
MapNode data[MapBlock::nodecount];
BlockPlaceholder()
{
for (std::size_t i = 0; i < MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE; i++)
for (std::size_t i = 0; i < MapBlock::nodecount; i++)
data[i] = MapNode(CONTENT_IGNORE);
}
} block_placeholder;
/*
QueuedMeshUpdate
*/
@@ -225,12 +227,13 @@ void MeshUpdateWorkerThread::doUpdate()
while ((q = m_queue_in->pop())) {
if (m_generation_interval)
sleep_ms(m_generation_interval);
porting::TriggerMemoryTrim();
ScopeProfiler sp(g_profiler, "Client: Mesh making (sum)");
MapBlockMesh *mesh_new = new MapBlockMesh(m_client, q->data, *m_camera_offset);
MeshUpdateResult r;
r.p = q->p;
r.mesh = mesh_new;