Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13250 closed enhancement (fixed)

[Patch] JOSM seems to hang after sorting members of a complex relation

Reported by: GerdP Owned by: team
Priority: normal Milestone: 16.07
Component: Core Version:
Keywords: Performance Relation Editor Cc:

Description

Select a multipolygon relation with > 6000 members, e.g. 6040654
Edit the relation
Click on the sort members icon

After a short time (maybe 4 seconds) all members are marked as changed but
JOSM doesn't respond for minutes (no idea how long it will take)

The time is consumed in a loop that invokes
boolean org.openstreetmap.josm.gui.util.HighlightHelper.highlightOnly(Collection<? extends OsmPrimitive> prims)
with an Arraylist, and for this List the contains() method is called.

If I got that right, this is repeated for each member, and the list is growing with each member,
so after some iterations you have a sequential search on thousands of elements, repeated for thousands of times.
Using a Hashset instead of an ArrayList improves performance heavily, but maybe the problem
could be solved better elsewhere. Attached is a patch that shows where to use the HashSet.

Attachments (2)

member_sort_performance.patch (1.1 KB) - added by GerdP 4 years ago.
memberTable_performance.patch (4.6 KB) - added by GerdP 4 years ago.
performance patch for relation editor

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by GerdP

comment:1 Changed 4 years ago by Don-vip

Milestone: 16.07

comment:2 Changed 4 years ago by Don-vip

Resolution: fixed
Status: newclosed

In 10683/josm:

fix #13250 - JOSM seems to hang after sorting members of a complex relation (patch by gpetermann_muenchen)

comment:3 Changed 4 years ago by Don-vip

thanks for the patch! :)

Changed 4 years ago by GerdP

performance patch for relation editor

comment:4 in reply to:  3 Changed 4 years ago by GerdP

Resolution: fixed
Status: closedreopened

Replying to Don-vip:

thanks for the patch! :)

Thanks for committing :)
I've done a bit more research and - as I thought before - the real problem is that
some routines call the method addSelectionInterval(int index0, int index1)
in a loop which passes the same values for index0 and index1.
This happens for most actions in the relation editor, and thus makes it slow
with relations with many members.

Attached is a 2nd patch memberTable_performance.patch which avoids this problem.
It 1st collects the indices which should be selected in a BitSet and than
calls addSelectionInterval for each group, e.g. if 1,2,3,6,7,8 are selected
it performans two calls (1,3 and 6,8) instead of six. If all +6000 members are selected,
a single call is done within a fraction of a second.

comment:5 Changed 4 years ago by Don-vip

Resolution: fixed
Status: reopenedclosed

In 10700/josm:

fix #13250 - performance optimization when sorting sorting members of a complex relation (patch by gpetermann_muenchen)

comment:6 Changed 4 years ago by Don-vip

thanks again!

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.

Add Comment


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

 
Note: See TracTickets for help on using tickets.