possible tuning for evaluation of tags

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

Hi Gerd, as for point 2, it reminds me ideas from topic "conditional includes in style". What about supporting that kind of structure in style: barrier=* { do { bicycle=* { set ... } foot=* { set ... } hgv=* { set ... } motorcar=* { set ... } } } -- Best regards, Andrzej

Hi Andrzej, yes, I also thought about this, but more in the opposite direction. I hope that my change doesn't make that more complicated ;-) I've just started a new branch performance2 where I will commit changes which should only have an influence on performance. I think this will take maybe 10 days. In the end, we can decide if the faster version is still easy to understand and to maintain. Gerd
Date: Tue, 29 Apr 2014 14:45:02 +0200 From: popej@poczta.onet.pl To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] possible tuning for evaluation of tags
Hi Gerd,
as for point 2, it reminds me ideas from topic "conditional includes in style". What about supporting that kind of structure in style:
barrier=* { do { bicycle=* { set ... } foot=* { set ... } hgv=* { set ... } motorcar=* { set ... } } }
-- Best regards, Andrzej _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (2)
-
Andrzej Popowski
-
Gerd Petermann