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?
- Open a large dataset (I'v used bus stops in Hungary, from Overpass)
- Select all objects (Ctrl+A)
- Open up the preset search menu (F3)
- Start typing something,
descriptionfor 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
369 369 if (!suitable && preset.types.contains(TaggingPresetType.RELATION) 370 370 && preset.roles != null && !preset.roles.roles.isEmpty()) { 371 371 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)); 373 374 // keep the preset to allow the creation of new relations 374 375 } 375 376 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



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