-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store tangram geometry in pin #4897
Store tangram geometry in pin #4897
Conversation
This sounds good, the implementation is also good. Two ideas for further improvement:
|
I remember that too. There was no measureable performance improvement, and the memory improvement is probably not worth it: using this info we may save somthing like 8 bytes per entry, and 16 bytes per map. For a high density area with 10k pins in view, this would be ~720 kB. But if it's really simple to do... (I didn't look at it)
Though for quests there are 7 entries, and default initial capacity is 16. Does unused capacity use memory? |
Yes, of course. But the more important thing is that it doesn't grow. |
This would help performance in areas with high density of quests, but would require putting the quests/quest pins into a HashMap<LatLon, Quest(Pin)> first. I think, probably not worth it because there are not that many that are actually on top of each other. They only seem that way because they appear after one another, e.g. width after lane, housenumber after building, roof shape after levels, lit after sidewalk (or other way round?), ... |
I was about to start a PR when I noticed that this is might need further changes, as the road colors depend on theme. |
You could not set it in the |
Ah nvm, not that easy as can't access the props in the tangram geometry once ist has been constructed |
I think the only possibility would be to not have the |
I added some logging and waited for an automatic theme switch. |
Sounds like this could be done then |
Found it: https://github.com/streetcomplete/StreetComplete/pull/4152/files What I found to save a lot more is string interning when loading elements / tags from database: 4 MB saved for 38k elements, at the cost of ~5% slower loading. |
Hmm... yeah, that sounds like it make sense. On the other hand, memory is usually in ample supply so that memory-optimization at the cost of CPU is rarely worth it. Also, I am a bit skeptic if it is a good idea to intern every trash value that can be found in the OSM database. Maybe just the keys? Anyway, if you are looking into interning, the first thing that comes to my mind is to intern the string elements (keys, values, but probably not the regex stuff) of the filter syntax during parsing. |
Some more detailed results (averaged over a few runs, memory use after GC):
I have no clue why creating an additional |
I think it is not really worth it. |
Alright, then let's leave it as it is |
Currently a tangram
Point
is created for each pin every timePinsMapComponent.set
is called.By storing the tangram geometry in the pin, this can be avoided, which improves performance of
PinsMapComponent.set
by roughly 30%, and reduces need for garbage collection.Actually the change is only used when using
QuestPinsManager.updateQuestPins
(mostly after answering / hiding a quest), other calls toPinsMapComponent.set
always use newPin
s. Still it's an improvement, as solving quests happens quite often.(a similar change is possible for
StyleableOverlayMapComponent
)