Skip to content

Commit 3ceb0d4

Browse files
Limit meshing to 1 thread (#1254)
On my 16 core CPU Amulet was maxing out the whole processor but was not getting much of a speed boost. I think most of the CPU time is spent spawning and destroying threads because the work being done is so small. After profiling it seems that adding more threads makes it a little faster but not much. Using all cores makes it run slower than just one. I think most of the benefit is from running the meshing code independently of the GIL. I have decided to limit meshing to 1 thread. Tests (times in seconds + frames out of 60) range with gil = 41+19 prange(cpu) = 33+24 prange(4) = 31+05 prange(2) = 31+14 prange(1) = 31+36
1 parent e5b46bc commit 3ceb0d4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

amulet_map_editor/api/opengl/mesh/level/chunk/chunk_builder_cy.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ cdef tuple _create_lod0_chunk(
366366
chunk_offset[2]
367367
)
368368

369-
for i in prange(sub_chunk_count, nogil=True):
370-
# for i in range(sub_chunk_count):
369+
for i in prange(sub_chunk_count, nogil=True, num_threads=1):
371370
sub_chunk_verts[i] = create_lod0_sub_chunk(
372371
block_array_list[i],
373372
block_model_manager,

0 commit comments

Comments
 (0)