#23468 closed enhancement (fixed)
Performance issue with Validator tree window
Reported by: | GerdP | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 24.02 |
Component: | Core validator | Version: | |
Keywords: | performance | Cc: | simon04 |
Description
Situation: Have a large dataset downloaded with overpass api and run validator with informational messages enabled. In my case I have > 560.000 entries in the tree and - probably most important - lots of results from TagChecker:
Presets do not contain property key (529 359) Presets do not contain property value (3 081)
I've closed the validation layer as it slows down any zooming or paning drastically and I've zoomed in so that only a few nodes are visible. So far so good. JOSM is usable.
Steps to reproduce the performance issue:
- Open new data layer (e.g. to download data from OSM and fix one important error), note that the validation tree windows is emptied (correct)
- close the (small) data layer. Note that JOSM doesn't react for quite a while (17 secs in my case) before JOSM shows the validation results for the large dataset. (which didn't change)
I found out that most of the time is spent in OsmValidator.getErrorsBySeverityMessageDescription()
which was written for #14704, esp. in AlphanumComparator.compare()
.
I wonder if there is a good reason to use this complex comparator instead of String.compare() which is much faster. I see difference in the order of messages but I wouldn't say one order is better than the other.
Attachments (2)
Change History (14)
by , 15 months ago
Attachment: | 23468.patch added |
---|
comment:1 by , 15 months ago
comment:2 by , 15 months ago
Cc: | added |
---|
comment:3 by , 15 months ago
Looking at some profiling data, it looks like most of the time is spent in RuleBasedCollator
, and more specifically, in the normalization phase for it in StringBuilder.append
.
That normalization phase would be so that the following entries are in the expected order:
Doolittle
Ḗttiene
Ettiene
Foobar
Standard String::compareTo
ordering:
[Doolittle, Ettiene, Foobar, Ḗttiene]
With the Collator
ignoring accented letters:
[Doolittle, Ettiene, Ḗttiene, Foobar]
We can try to detect ascii only strings and use String::compareTo
for those.
I'll upload a sample patch so you can check to see if it will work for your test area.
Notes on the patch:
getChunk
returns a substring of the string that was passed in -- the method does no transformations, it just appends the character for each position to aStringBuilder
.- Chunk comparison code was extracted to its own method (for profiling purposes, but it also makes the methods a bit easier to read)
- New
isAscii
method to avoidCollator
comparison methods wherever possible. Most significant performance gains will be in areas with no accented letters.
EDIT: Profiler comparison for attachment:23468.2.patch using Mesa County, Colorado
as the source data:
- CPU: -86.4% (3.366s to 0.459s) -- I would expect your test area to be ~2.5s, down from 18.5s.
- Memory: -99.9% (2.37GB to 2.07 MB)
by , 15 months ago
Attachment: | 23468.2.patch added |
---|
Alternative to attachment:23468.patch where AlphanumComparator
is optimized
comment:4 by , 15 months ago
Works fine for me. Time with this patch is 1.0 secs which is still much better than the original 18.5 secs.
comment:5 by , 15 months ago
Better than I expected. There might have been some additional optimizations done by the JVM after some time -- one of my profiler runs appears to have compiled both compareChunk
and getChunk
to "native" code.
comment:7 by , 15 months ago
Milestone: | → 24.02 |
---|
comment:8 by , 15 months ago
Summary: | Performace issue with Validator tree window → Performance issue with Validator tree window |
---|
comment:9 by , 15 months ago
This caused a test to fail. I may have to back it out if I cannot figure out a way to get (
and _
to have the "right" order.
I really don't want to though. :(
Experimental patch to measure elapsed time in
OsmValidator.getErrorsBySeverityMessageDescription()
and use String.compare() in dialog.Elapsed time with AlphanumComparator: ~18.5 secs
Elapsed time with String.compare(): ~0.1 secs
This time is also spent when the dialog shows the progress bar with the text "Updating ignored errors".