#13956 closed enhancement (fixed)
[Patch] Possible memory optimization with presets cache
| Reported by: | Don-vip | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 17.05 |
| Component: | Core | Version: | |
| Keywords: | performance memory | Cc: | bastiK, GerdP, kendzi |
Description
It seems we have two maps storing the same data twice, for about ~400Kb of memory each:
- TagChecker.presetsValueData:
/** The spell check preset values */ private static volatile MultiMap<String, String> presetsValueData;
- AutoCompletionManager.PRESET_TAG_CACHE:
/** * the same as tagCache but for the preset keys and values can be accessed directly */ protected static final MultiMap<String, String> PRESET_TAG_CACHE = new MultiMap<>();
This cache could be moved to TaggingPresets class and used everywhere in the application.
Attachments (5)
Change History (25)
by , 9 years ago
| Attachment: | 13956_v1.patch added |
|---|
comment:1 by , 9 years ago
by , 9 years ago
| Attachment: | 13956_v2.patch added |
|---|
comment:3 by , 9 years ago
v2 also moves PRESET_ROLE_CACHE from AutoCompletionManager to TaggingPresets. This allows to simplify the code in
AutoCompletionManager.
Probably I should use getters instead of public structures in TaggingPresets?
comment:4 by , 9 years ago
Thanks!
- one small typo: additinalPresetsValueData without "o"
- yes getters are welcome :)
by , 9 years ago
| Attachment: | 13956_v3.patch added |
|---|
comment:5 by , 9 years ago
| Summary: | Possible memory optimization with presets cache → [Patch] Possible memory optimization with presets cache |
|---|
comment:6 by , 9 years ago
A note since you are optimizing for memory/performance:
getPresetKeysdoes not need to create a copy - a simpleunmodifiableSetwould be enough.
Other than that, I think moving the cache to TaggingPresets is a matter of taste - but it seems to make the code cleaner.
I personally would change TaggingPresetItem, so that cachePresetItem can use the visitor pattern. It would make it easier for plugins and for us to add custom item types.
by , 9 years ago
| Attachment: | 13956_v4.patch added |
|---|
comment:7 by , 9 years ago
Yes, I don't know why I didn't use unmodifiableSet here. I also think that TaggingPresets.getTaggingPresets() should use
unmodifiableCollection instead of creating a copy.
I've implemented these changes with v4.
Reg. visitor pattern: Sorry, I am not used to think in this pattern. Maybe you can create a 2nd patch which would help me to learn it.
comment:8 by , 9 years ago
We can do this later.
If there are no objections, I would like to apply the patch the way it is now.
comment:10 by , 9 years ago
| Milestone: | 16.12 → 17.01 |
|---|
by , 9 years ago
| Attachment: | 13956_v5.patch added |
|---|
comment:12 by , 9 years ago
| Milestone: | 17.01 → 17.02 |
|---|
comment:13 by , 9 years ago
| Milestone: | 17.02 → 17.03 |
|---|
comment:14 by , 9 years ago
| Milestone: | 17.03 → 17.04 |
|---|
comment:15 by , 9 years ago
| Milestone: | 17.04 → 17.05 |
|---|
comment:18 by , 8 years ago
| Cc: | added |
|---|
This change breaks "JOSM Integration" - I find the output always hard to read, but it seems kendzi3d is broken?



Not sure if that improves much.
TagCheckerstores additional values in its version of the map, so one needs additional code. See attached patch.