Reduce number of AgencyId instances - #387
Conversation
|
This is very promising - thanks! Since the last round of optimizations, I've identified the very inefficient storage of shape points as a major driver of OTP memory consumption and have reworked it in OTP: opentripplanner/OpenTripPlanner#6752 You could check out |
|
BTW, how big are the memory savings in your tests? |
|
Just printing the memory via those small utils seem to give about the same as profilers. This is just parsing the shape file. ParseShapePrintMemory:Total Memory: 11136 MB LegacyParseShapePrintMemory:Total Memory: 13792 MB ParseShapeStringInterningPrintMemoryTotal Memory: 7680 MB LegacyParseShapeStringInterningPrintMemoryTotal Memory: 8864 MB Kind of surprising to see that string interning is worse off. Should try this with parsing all files too. |
|
Maybe you could double the check the numbers here, my tests seems to indicate String interning is no longer necessary. According to |
|
The above memory usage numbers are straight after parsing, but before freeing up the reader and such. This table is after all is done, keeping just the
So still seems like an improvement in memory usage (and skipping interning all together is still an option). |
|
For the whole feed:
I was expecting more memory use in general, but these are the measurements so far. Maximum memory use must be taken with a grain of salt, not necessarily so important or accurate. |
|
Again, this looks like excellent, methodical work. Unfortunately, I'm at the OTP conference next week so this will have to wait a bit longer. However, so far I can say that I would like to enable the most aggressive memory optimizations. Some side notes:
|
|
I'm back from the conference and can review again if you want to get this into a reviewable state - perhaps rebase on top of main. |
|
It seems that by selectively configuring string interning per entity, i.e. disabling it for |
|
Disabling interning for shapes: So this seems to indicate that interning takes a lot of time. |
Yes, but then the memory usage is permanent even for numeric strings etc. I think string interning is good as is. |
5301a40 to
a2c846d
Compare
|
|
||
| private Map<String, String> _stringTable = new HashMap<>(); | ||
|
|
||
| private Predicate<Class> _internStringsDisabled; |
There was a problem hiding this comment.
Using _ in the field names read like Python. Please don't spread it even more. If you want, you can change all the field names in this class.
There was a problem hiding this comment.
I agree, but still better to have a single convention within the library.
|
Also stop_times.txt is often large. Does it pay off profiling the id interning there? (This can come in a separate PR.) |
leonardehrenfried
left a comment
There was a problem hiding this comment.
I have a few requests.
Plain interning seems to save about 80 MB memory and run 1 second (6 vs 7) slower. |
Less memory usage for huge
ShapePoint(2 GB) files.Add "interning" of
AgencyIdfor entity types which repeat the same id many times.Works best if
Stringinterning is disabled, but even when enabled it seems to save a good chunk of memory. Performance is approximately as before.Added a few utils classes the help profile memory (can be deleted later).
TODO
HashMapis acceptable