Modify

Opened 10 months ago

#24188 new enhancement

[WIP patch] Speed up tagging preset filtering

Reported by: gaben Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: template_report performance preset Cc:

Description

What steps will reproduce the problem?

  1. Open a large dataset (I'v used bus stops in Hungary, from Overpass)
  2. Select all objects (Ctrl+A)
  3. Open up the preset search menu (F3)
  4. Start typing something, description for example

What is the expected result?

JOSM is somewhat responsive, even knowing the huge data in memory.

What happens instead?

JOSM is barely reaches responsive definition, around 1 char/s input speed.

Please provide any additional information below. Attach a screenshot if possible.

The fix makes it 2.5 times faster in my use case and the responsiveness is there.

What is happening is that JOSM is going through all presets with role definitions and then trying to regex match the selected object. Yes, all of them, one by one. Matching takes a lot of time, so prefiltering helps, but I need to make sure nothing broke, therefore marked as WIP.

  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

     
    369369                    if (!suitable && preset.types.contains(TaggingPresetType.RELATION)
    370370                            && preset.roles != null && !preset.roles.roles.isEmpty()) {
    371371                        suitable = preset.roles.roles.stream().anyMatch(
    372                                 object -> object.memberExpression != null && selectedPrimitives.stream().anyMatch(object.memberExpression));
     372                                role -> role.memberExpression != null
     373                                        && selectedPrimitives.stream().filter(preset::typeMatches).anyMatch(role.memberExpression));
    373374                        // keep the preset to allow the creation of new relations
    374375                    }
    375376                    if (!suitable) {
Revision:19342
Is-Local-Build:true
Build-Date:2025-03-02 12:46:28

Identification: JOSM/1.5 (19342 SVN en) Linux Ubuntu 22.04.5 LTS
Memory Usage: 314 MB / 3988 MB (207 MB allocated, but free)
Java version: 21.0.6+7-Ubuntu-122.04.1, Ubuntu, OpenJDK 64-Bit Server VM

Attachments (1)

josm_24188.patch (1.3 KB ) - added by gaben 10 months ago.
this seem to work correctly, but has a bit worse performance, only 2.3x speedup

Download all attachments as: .zip

Change History (1)

by gaben, 10 months ago

Attachment: josm_24188.patch added

this seem to work correctly, but has a bit worse performance, only 2.3x speedup

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to gaben.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


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