Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#5627 closed enhancement (fixed)

[PATCH] Speedup of node drawing

Reported by: bilbo Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: Cc:

Description

1) org.openstreetmap.josm.data.osm.Node.isConnectionNode() is relatively expensive (get list of referrers, then filter it for ways, then check size of list) and takes for about 14% of CPU time spent in org.openstreetmap.josm.gui.mappaint.SimpleNodeElemStyle.paintPrimitive().

I added isReferredByWays(N) to OSMPrimitive which merely checks for being referred by N or more ways and it is faster (no list is created and filtered, only number of referred Ways is counted and compared)

Also, this still relatively expensive function is called 3 times during painting. I modified the code to call it only once and store the result.

2) org.openstreetmap.josm.data.osm.Node.getEastNorth() is called 4 times during painting, eating 12% of CPU time instead of 3% needed in case of single call and storing the value for further comparisons

3) Some minor changes, like calculating size AFTER checking whether to paint the node at all...

This patch should improve time needed to repaint nodes by about 15% to 20%. While it is faster, it is still pretty slow .... moving "map" with just 420000 untagged nodes on core i7 is very choppy with about only 3 redraws per second.

Ideas for further improvement:

Store number of ways and relations referring primitive, then just read the counter (speedup, but at cost of having extra 2 ints per primitive) - maybe there is other code that would benefit from this? Some code that merely needs to know whether a node/way is part of another way/relation without needing to know the list?

It is not necessary to check in MapPainter.drawNode/drawNodeIcon whether node lies within boundaries - this is done already in MapPaintVisitor.drawNode, but is it possible to paint nodes somewhere else? Perhaps the check is useless and it can go away.

Attachments (1)

optimize-speed.patch (5.9 KB ) - added by bilbo 14 years ago.
Patch to improve speed of drawing nodes

Download all attachments as: .zip

Change History (3)

by bilbo, 14 years ago

Attachment: optimize-speed.patch added

Patch to improve speed of drawing nodes

comment:1 by bastiK, 14 years ago

Resolution: fixed
Status: newclosed

In [3653/josm]:

applied #5627 (patch by bilbo) - Speedup of node drawing

in reply to:  description comment:2 by bastiK, 14 years ago

Replying to bilbo:

Ideas for further improvement:

Store number of ways and relations referring primitive, then just read the counter (speedup, but at cost of having extra 2 ints per primitive) - maybe there is other code that would benefit from this? Some code that merely needs to know whether a node/way is part of another way/relation without needing to know the list?

Yes, might be a good idea to separate way and relation referrers because in many situation you have to filter one of these two referrer types.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.