logo separator

[mkgmap-dev] possible tuning for evaluation of tags

From Gerd Petermann gpetermann_muenchen at hotmail.com on Tue Apr 29 09:14:12 BST 2014






Hi Programmers,

according to Java Mission Control the current code in mkgmap 
requires ~ 20% of the CPU time in Tags.keyPos(),
and a few more percent in other HashMaps related to tag keys.
A lot of this CPU time is required to compare the keys of tags 
(which are String instances),  which also causes quite a lot of data 
being moved into CPU caches.

There are two ways to reduce this CPU time:
1) reduce the time required in Tags.keyPos()
This can be done if we use a dictionary to translate each 
used tag key into a unique id (a short or int). Instead of storing and comparing
Strings we could then use the id, which in turn can be the index
to an array with the tag key.

2) reduce the number of calls of Element.getTag() which calls Tags.keyPos()
This can be done by some caching. Consider the following rules
barrier=* & bicycle=*    { set mkgmap:bicycle='${bicycle|subst:private=>no}' }
barrier=* & foot=*       { set mkgmap:foot='${foot|subst:private=>no}' }                  
barrier=* & hgv=*        { set mkgmap:truck='${hgv|subst:private=>no}' }                  
barrier=* & motorcar=*   { set mkgmap:car='${motorcar|subst:private=>no}' } 

The result for the evaluation of tag barrier=* is a constant as none of the action blocks
changes it, but mkgmap really calls Element.getTag() again and again for each line.

In March 2012 I did some experiments with this idea and found a typical saving of 20%
run time with the default style, but I never finished it.

I think it is worth to start this again in a new branch, but it will involve a lot of small changes
to many sources, so I'd like to know if anybody else plans to code changes.

Gerd




 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20140429/86bd56dc/attachment.html>


More information about the mkgmap-dev mailing list