Skip to content
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

Split shared memory into updatable and non-updatable section #5002

Merged
merged 6 commits into from
Apr 6, 2018

Conversation

TheMarex
Copy link
Member

@TheMarex TheMarex commented Apr 5, 2018

Issue

This is a simple version of #4873 that still works on per-file granularity. To make this more effective we need to split the weights from the MLD graph and refactor the way we update speeds (to work on a graph not an edge list).

Preliminary measurements on California show that this reduces peak memory usage by 25%.

Tasklist

Requirements / Relations

Based on #4982

@TheMarex TheMarex force-pushed the feature/updatable_shm branch from 76dad11 to 59e2d93 Compare April 6, 2018 00:09
@TheMarex TheMarex added this to the 5.17.0 milestone Apr 6, 2018
@TheMarex TheMarex requested a review from oxidase April 6, 2018 00:50
@TheMarex TheMarex self-assigned this Apr 6, 2018
@chaupow chaupow self-requested a review April 6, 2018 10:49
@@ -17,4 +17,27 @@ Feature: osrm-datastore command line options: list
Then it should exit successfully
When I try to run "osrm-datastore --list"
Then it should exit successfully
And stdout should contain "test_dataset_42/data"
And stdout should contain "test_dataset_42/static"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add And stdout should contain "test_dataset_42/updatable" too

@@ -43,18 +43,24 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
boost::interprocess::scoped_lock<mutex_type> current_region_lock(barrier.get_mutex());

auto &shared_register = barrier.data();
auto region_id = shared_register.Find(dataset_name + "/data");
if (region_id == storage::SharedRegionRegister::INVALID_REGION_ID)
auto static_region_id = shared_register.Find(dataset_name + "/static");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could replace auto with storage::SharedRegionRegister::RegionID 🤷‍♀️
code style nitpick and up to you whether you want to pick it up or not 😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer the short version, since it makes changes to the code easier. For example, when renaming the type storage::SharedRegionRegister::RegionID it should not break the code in too many places.

I found that in most cases it is good practice to write your code type-safe but also type-agnostic, meaning the type information is used by the compiler to find errors, but when reading the code you don't really have to care about the types that much. I think the short rule was: "auto whenever possible".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea. i can live with both. they have their advantages and disadvantages 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheMarex sounds like Swift :-)

@TheMarex TheMarex force-pushed the feature/updatable_shm branch from c1f39a8 to fb1540e Compare April 6, 2018 11:20
Copy link
Member

@chaupow chaupow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it looks good

std::unordered_map<std::string, contractor::ContractedMetricView> metrics = {
{metric_name, std::move(contracted_metric)}};

std::uint32_t graph_connectivity_checksum = 0;
contractor::files::readGraph(
config.GetPath(".osrm.hsgr"), metrics, graph_connectivity_checksum);

if (turns_connectivity_checksum != graph_connectivity_checksum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to remove this check? is it impossible to keep this check because .hsgr is now part of updatable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I forgot about removing this. Thinking about this, there is probably a way to retain this. 👍

std::uint32_t graph_connectivity_checksum = 0;
partitioner::files::readGraph(
config.GetPath(".osrm.mldgr"), graph_view, graph_connectivity_checksum);

if (turns_connectivity_checksum != graph_connectivity_checksum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

@TheMarex
Copy link
Member Author

TheMarex commented Apr 6, 2018

I investigated the coverage failures and it seems like the alternatives acting up. :-/

@TheMarex TheMarex merged commit b08191b into master Apr 6, 2018
@TheMarex TheMarex deleted the feature/updatable_shm branch April 6, 2018 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants