Skip to content

Experiment: Optimization of street edge notes

Andrew Byrd edited this page Dec 17, 2014 · 1 revision

Some results for ticket #1529, on suppressing notes / wheelchair notes sets in street edges.

Results

The graph memory size reduction is about 13%.

Below memory statistics:

     Graph size            Class size
         (mem)     (disk)  EPS   PSE   Gain (mem)
----------------------------------------------------
A    304946000  119786150  32    88    --
B    265267000   91458168  32    80    13%
C    264909000   91349425  32    80    0.13%
----------------------------------------------------
(Number of PlainStreetEdge objects: 353894)
  • A - original version (with elevation profile optimizations)
  • B - A + note set removed (external index)
  • C - B + note interning + note i18n

Note: Interning gain only 0.13% as there are only few notes on the test graph. If the number of notes increase in the long term the gain can only increase.

Note: The removal of note set in state/state data does not appear here (memory usage are for static graph without request). The gain in term of memory on state is hard to profile as it depends on both the number of concurrent requests and the average search space in number of states. For large heavy-loaded graphs this gain may be not negligible however (2 pointers removed from the state data).

Implementation details

Some comments on implementation:

  • We use a StreetNoteService to take care of the edge->notes index. When adding / removing an edge we need to go through this service to handle the changes (splitting edges, removing temporary edges...)
  • The state data do not contain the set of notes applicable to the step anymore. This help reduce memory usage and speed during route planning (this change reduce the number of state data cloning, as there was two clones for each edge transition with notes).
  • The notes are attached to the final itinerary only later on, in PlanGenerator, with the help of the StreetNoteService. The note index is only scanned for the final itinerary plan for a few edges, and not for all states.
  • Each note is attached to a "NoteMatcher" to specify if the note apply for a specific state/edge pair. This change allow the merge of all notes ("toll", "wheelchair", normal notes) in a consistent manner. This also help reduce code complexity and allow for more flexible note handling.
  • I18n now works for all notes, not only wheelchair notes.
  • Notes and matchers are interned, to reduce memory usage. Most of the notes are identical (toll roads, unpaved surface, mud, etc...) and matchers too (wheelchair matcher, bicycle matcher...)

Possible improvements

As suggested by @JordenVerwer we could remove all synchronization issues on the edge->note index by splitting the note indexing in two:

  • A static only note index, for static edges built at graph compilation time, thus not needing synchronization (read-only index)
  • A temporary note index, either in the RoutingContext or in the PartialPlainStreetEdge, for temporary edges. This is local and visible only to a single client request context / thread so no synchronization are needed.

The documentation on this wiki is outdated and should not be used

unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs

Clone this wiki locally