[geos-devel] JTS/GEOS performance - smart-ptr vs ref counting

Chapman, Martin MChapman at sanz.com
Mon Jan 31 23:05:32 EST 2005


Martin,
 
I don't think storing points in an stl vector is the problem.  I think the problem is definitely the copying of the point arrays many times, and allocating/deallocating lots of objects in every loop.  As an example, I use to process points by having a controlling loop that called different functions to process different geometry types (point, linestring, polygon, etc...).  When I moved the code from the functions all into the same function as my loop I saved tons of memory and gained a lot of speed.  The efficiency came from not allocating and deallocating a new stack frame for every geom I think.  Also, I removed all objects that were created inside of the loop and initialized them at the top of my function.  Then each loop I just re-assign the pointer.  This makes a noticable diff when processing tens of millions of coordinates.  Your slowness isn't initializing your points from what I understand.  It's when you do processing on the points that's slow...correct?  If that's the case then I would guess it's in your looping.
 
I think the bottom line is what someone said earlier though.  It will be a good guess at best and a lot of trial and error until you use an optimizer that can pin down what is taking the most time and resources.  We use an optimizer at work for Java and it is the bomb.  It makes us all look stupid (which by the way is not very hard).
 
Also, you guys should take a look at Frank Warmerdam's OGR code.  That code is pretty fast, although he doesn't have any notable spatial algorithms outside of geos.  His object structures are good though.  
 
P.S.  I always thought that geos should be merged into ogr and not the other way around.  Then you could read data really fast and just do spatial operations on the ogr points without having to re-copy them to geos geometry structures...just a thought.
 
Martin

	-----Original Message----- 
	From: Martin Davis [mailto:mbdavis at VividSolutions.com] 
	Sent: Mon 1/31/2005 6:48 PM 
	To: GEOS Development List 
	Cc: 
	Subject: FW: [geos-devel] JTS/GEOS performance - smart-ptr vs ref counting
	
	

	> It might be worth looking into special memory managers but AFAICT
	> most of the 'coordinates' are actually stored in STL vectors
	> and these
	> are generally about as efficient as you can get at minimizing
	> allocation costs.
	
	That's good to hear.
	
	How would you interpret the significance of strks allocation counts he
	posted earlier in this thread?  There's a lot of objects being allocated
	there.  Might that not imply that memory allocation is a hotspot?
	
	And there is still the undeniable fact that JTS is faster than GEOS - in
	spite of it having to rely on the hopelessly inefficient garbage
	collection strategy of that environment.  8^)
	
	Martin Davis, Senior Technical Architect
	Vivid Solutions Inc.      www.vividsolutions.com
	Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
	Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046
	
	
	_______________________________________________
	geos-devel mailing list
	geos-devel at geos.refractions.net
	http://geos.refractions.net/mailman/listinfo/geos-devel
	



More information about the geos-devel mailing list