Opened 16 months ago
Closed 16 months ago
#23097 closed defect (fixed)
[PATCH] Significantly reduce allocations during startup in XmlObjectParser and PluginListParser
Reported by: | taylor.smock | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 23.08 |
Component: | Core | Version: | |
Keywords: | performance startup | Cc: |
Description
With the Name Suggestion Index preset added to JOSM, the following methods are relatively expensive during startup (mem old -> mem new, cpu old -> cpu new):
XmlObjectParser$Entry.getField
(124 MB -> 8.1 MB, 501ms -> 99ms)XmlObjectParser$Entry.getMethod
(126 MB -> 452 kB, 292ms -> 45ms)
The gains are almost entirely from getting rid of copy calls to Method and Field (done when calling Class.getMethods()
and Class.getFields()
). There are further gains in JVM methods (like GC), but those can be a bit ticklish to profile correctly. It does look like a 20% improvement there though (32,653ms -> 26,075ms).
Note: I'm also including a change in PluginListParser
to avoid compiling a pattern over and over again. That reduces the cost of PluginListParser.parse
from 25.5 mb to 12.1 mb and 217ms to 162ms. Most of the remaining cost is stuff we cannot do anything about.
Additional note: The PluginListParser numbers included the cost of interning the strings. I ended up removing that since code analysis indicated that the strings were not kept long-term.
I might want to add the following to the patch:
src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
This removes 7.2 MB of allocations if all plugins have been downloaded.