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

Ignore unused egress modes in network preloader #789

Merged
merged 4 commits into from
Apr 4, 2022

Conversation

abyrd
Copy link
Member

@abyrd abyrd commented Feb 16, 2022

This avoids building huge bike egress tables when that egress mode is specified but no transit is enabled. later during routing, the egress tables should only be retrieved by the PerTargetPropagater which should only be created when transit is in use.

abyrd and others added 2 commits February 16, 2022 20:32
this avoids building huge bike egress tables when that egress mode
is specified but no transit is enabled. later during routing, the
egress tables should only be retrieved by the PerTargetPropagater
which should only be created when transit is in use.
@abyrd abyrd marked this pull request as ready for review March 25, 2022 08:30
@abyrd abyrd enabled auto-merge March 25, 2022 08:32
@@ -186,7 +184,11 @@ public Key (AnalysisWorkerTask task) {
// transit is used). See code in TravelTimeComputer for when each is used.
// Egress modes must be tracked independently since we need to build EgressDistanceTables for those.
this.allModes = LegMode.toStreetModeSet(task.directModes, task.accessModes, task.egressModes);
Copy link
Member

Choose a reason for hiding this comment

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

It appears that the egress modes are still added to the "all modes" enum set. Do we want that to occur?

The following snippet could be used in order to create the "all modes" enum set from the filtered egress modes set:

            // Egress modes must be tracked independently since we need to build EgressDistanceTables for those.
            this.egressModes = LegMode.toStreetModeSet(
                // Avoid unnecessarily building egress tables by
                // ignoring spurious egress modes in requests that do not have transit enabled.
                task.transitModes.isEmpty() ? EnumSet.noneOf(LegMode.class) : task.egressModes
            );
            // We need to link for all of access modes, egress modes, and direct modes (depending on whether
            // transit is used). See code in TravelTimeComputer for when each is used.
            this.allModes = LegMode.toStreetModeSet(task.directModes, task.accessModes);
            this.allModes.addAll(this.egressModes);

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, great suggestion. My change was skipping only the egress table construction, this should also skip the linkage step. Maybe the cleanest way of all would be to empty out the task.egressModes when task.transitModes.isEmpty(), but I didn't do it this way because there is no precedent for mutating/inferring fields of the supplied task so it was a bigger conceptual change.

Copy link
Member Author

Choose a reason for hiding this comment

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

We may still be "over-linking" because I believe the access mode linkages also won't be touched if transit is not used. Linking is usually faster than egress table building so this may not have much impact. We may eventually want to rewrite this so the preloader key has egressModes and linkageModes instead of allModes, but for now I think it's better to stick with this minimally disruptive change.

Copy link
Member

@ansoncfit ansoncfit left a comment

Choose a reason for hiding this comment

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

Looks good.

@ansoncfit ansoncfit disabled auto-merge April 4, 2022 19:54
@ansoncfit ansoncfit merged commit bde4541 into dev Apr 4, 2022
@ansoncfit ansoncfit deleted the ignore-unused-egress-modes branch April 4, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants