0

Addded intial region caching.

Loads all the offsets & timestamps @ start to share to worker proceses.
From
14609247 function calls (14608852 primitive calls) in 118.278 CPU seconds
to
12232301 function calls (12231906 primitive calls) in 75.825 CPU seconds
This commit is contained in:
Xon
2011-03-19 13:36:40 +08:00
parent 1ac922983f
commit 1afb2b3d53
4 changed files with 69 additions and 43 deletions

View File

@@ -556,13 +556,13 @@ def render_worldtile(quadtree, chunks, colstart, colend, rowstart, rowend, path)
imgpath = path + "." + quadtree.imgformat
world = quadtree.world
# first, remove chunks from `chunks` that don't actually exist in
# their region files
def chunk_exists(chunk):
_, _, chunkx, chunky, region = chunk
with open(region, 'rb') as region:
r = nbt.MCRFileReader(region)
return r.chunkExists(chunkx, chunky)
r = world.load_region(region)
return r.chunkExists(chunkx, chunky)
chunks = filter(chunk_exists, chunks)
#stat the file, we need to know if it exists or it's mtime
@@ -607,11 +607,9 @@ def render_worldtile(quadtree, chunks, colstart, colend, rowstart, rowend, path)
continue
# checking chunk mtime
with open(regionfile, 'rb') as regionfile:
region = nbt.MCRFileReader(regionfile)
if region.get_chunk_timestamp(chunkx, chunky) > tile_mtime:
needs_rerender = True
if needs_rerender:
region = world.load_region(regionfile)
if region.get_chunk_timestamp(chunkx, chunky) > tile_mtime:
needs_rerender = True
break
# if after all that, we don't need a rerender, return