#2033: Moving g.pnmcomp to lib/display to improve render performance of wxGUI ----------------------------------------------+----------------------------- Reporter: huhabla | Owner: grass-dev@… Type: enhancement | Status: new Priority: major | Milestone: 7.0.0 Component: wxGUI | Version: svn-trunk Keywords: display, Python, multiprocessing | Platform: All Cpu: All | ----------------------------------------------+-----------------------------
Comment(by huhabla): I am not fully convinced using the mmap() approach for IPC. It is not guaranteed that mmap() is faster then the usual file I/O.[1] I have written a small python script to test the performance of d.rast and d.vect using the north carolina sample dataset. The script is attached. I am using the PNG and Cairo driver, switching mmap on and of for different window sizes. In addition i call the d.rast (1x) and d.vect (2x) modules in parallel to measure a render speed gain. The composition is still missing, but i will add the PIL approach available in the grass wiki with python.mmap support. Here is the script: {{{ # -*- coding: utf-8 -*- from grass.pygrass import modules import os import time parallel = [True, False] drivers = ["png", "cairo"] mmap_modes = ["FALSE", "TRUE"] sizes = [1024, 4096] def render_image(module, driver="png", pngfile="test.png", size=4096, mapped="TRUE"): os.putenv("GRASS_RENDER_IMMEDIATE", "%s"%driver) os.putenv("GRASS_PNGFILE", "%s"%pngfile) os.putenv("GRASS_WIDTH", "%i"%size) os.putenv("GRASS_HEIGHT", "%i"%size) os.putenv("GRASS_PNG_MAPPED", "%s"%mapped) module.run() def composite_images(files): pass def main(): # Set the region modules.Module("g.region", rast="elevation", flags="p") for finish in parallel: if finish: print("*** Serial runs") else: print("*** Parallel runs") # Setup the modules rast = modules.Module("d.rast", map="elevation", run_=False, quiet=True, finish_=False) vectB = modules.Module("d.vect", map="streams", width=1, color="blue", fcolor="aqua", type=["area","line"], run_=False, quiet=True, finish_=finish) vectA = modules.Module("d.vect", map="roadsmajor", width=2, run_=False, quiet=True, finish_=finish) count = 0 for driver in drivers: for mode in mmap_modes: for size in sizes: start = time.time() count += 1 files = [] if mode == "TRUE": rast_file = "rast.bmp" vectA_file="vectA.bmp" vectB_file="vectB.bmp" else: rast_file = "rast.png" vectA_file="vectA.png" vectB_file="vectB.png" render_image(rast, driver=driver, pngfile=rast_file, size=size, mapped=mode) render_image(vectA, driver=driver, pngfile=vectA_file, size=size, mapped=mode) render_image(vectB, driver=driver, pngfile=vectB_file, size=size, mapped=mode) files.append(rast_file) files.append(vectA_file) files.append(vectB_file) # Wait for processes rast.popen.wait() vectA.popen.wait() vectB.popen.wait() # Composite the images composite_images(files) for file in files: os.remove(file) elapsed = (time.time() - start) print("*** Run %i Driver=%s mmap=%s Size=%i time=%f"%(count, driver, mode, size, elapsed)) main() }}} The result of the benchmark: {{{ GRASS 7.0.svn (nc_spm_08_grass7):~/src > python display_bench.py projection: 99 (Lambert Conformal Conic) zone: 0 datum: nad83 ellipsoid: a=6378137 es=0.006694380022900787 north: 228500 south: 215000 west: 630000 east: 645000 nsres: 10 ewres: 10 rows: 1350 cols: 1500 cells: 2025000 *** Serial runs *** Run 1 Driver=png mmap=FALSE Size=1024 time=0.796055 *** Run 2 Driver=png mmap=FALSE Size=4096 time=3.389201 *** Run 3 Driver=png mmap=TRUE Size=1024 time=0.449877 *** Run 4 Driver=png mmap=TRUE Size=4096 time=3.723065 *** Run 5 Driver=cairo mmap=FALSE Size=1024 time=0.824797 *** Run 6 Driver=cairo mmap=FALSE Size=4096 time=2.632125 *** Run 7 Driver=cairo mmap=TRUE Size=1024 time=0.542321 *** Run 8 Driver=cairo mmap=TRUE Size=4096 time=2.276822 *** Parallel runs *** Run 1 Driver=png mmap=FALSE Size=1024 time=0.756147 *** Run 2 Driver=png mmap=FALSE Size=4096 time=3.113990 *** Run 3 Driver=png mmap=TRUE Size=1024 time=0.530959 *** Run 4 Driver=png mmap=TRUE Size=4096 time=3.355732 *** Run 5 Driver=cairo mmap=FALSE Size=1024 time=0.865963 *** Run 6 Driver=cairo mmap=FALSE Size=4096 time=2.358270 *** Run 7 Driver=cairo mmap=TRUE Size=1024 time=0.566976 *** Run 8 Driver=cairo mmap=TRUE Size=4096 time=1.934245 }}} There is no mmap() speed improvement for the PNG driver for large window sizes? I will investigate this further. [1] http://lists.freebsd.org/pipermail/freebsd- questions/2004-June/050371.html -- Ticket URL: <http://trac.osgeo.org/grass/ticket/2033#comment:4> GRASS GIS <http://grass.osgeo.org> _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev