Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#5627 closed enhancement (fixed)

[PATCH] Speedup of node drawing

Reported by: bilbo Owned by: team
Priority: normal 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 3 years ago.
Patch to improve speed of drawing nodes

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by bilbo

Patch to improve speed of drawing nodes

comment:1 Changed 3 years ago by bastiK

  • Resolution set to fixed
  • Status changed from new to closed

In [3653/josm]:

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

comment:2 in reply to: ↑ description Changed 3 years ago by bastiK

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed .
as The resolution will be set. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.