valhalla / valhalla

Open Source Routing Engine for OpenStreetMap
https://valhalla.github.io/valhalla/
Other
4.42k stars 674 forks source link

Matrix should clear temp structures, but pre-reserve some space #4064

Closed nilsnolde closed 1 year ago

nilsnolde commented 1 year ago

The matrix algorithms don't reserve edge labels after they're done with one request, instead they're shrinking the structures to 0. Also seems like we should reuse() the adjacency lists.

I'd even keep more labels than the routing algos, 1 Mio is not a lot for the Dijkstras IMO (it's "just" a few MBs per thread). Either e.g. double the max_reserved_labels_count config for the matrix algos or introduce a new config? What do you think @dnesbitt61 @kevinkreiser ?

nilsnolde commented 1 year ago

Hm, ok, we can't resize the edge labels after a request is done in the Clear() method, bcs we don't want to reserve space for locations (they are vectors of label vectors, one per location for CostMatrix at least).. At least we can reserve a decent amount when initializing and reuse the double bucket queues.

nilsnolde commented 1 year ago

Hm, also it seems that no one ever calls any clear() methods on the matrix algos. That should happen in the matrix_action or at the end of the computation, but it doesn't. That also matches the observation a few people had a while ago (especially with our docker image for some reason) that RAM isn't freed after a request. Need to fix that asap IMO.