Skip to content

Commit

Permalink
Fix bliksemlabs#148, ban unsuitable journey_patterns at once
Browse files Browse the repository at this point in the history
Instead of high number of non cache-local look-ups for journey_pattern attributes and calendar's, check this once and ban all unsuitable journey_patterns
  • Loading branch information
koch-t committed Dec 16, 2014
1 parent 04228d1 commit 7054231
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions router.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ static void flag_journey_patterns_for_stop(router_t *router, router_request_t *r
if (i_jp == 0) return;

do {
#if RRRR_BANNED_JOURNEY_PATTERNS_BITMASK == 1
/* Don't check whether journeypattern is valid since we banned all unsuitable journey_patterns */
i_jp--;
bitset_set (router->updated_journey_patterns, journey_patterns[i_jp]);
#else
calendar_t jp_active_flags;

i_jp--;
Expand All @@ -212,13 +217,15 @@ static void flag_journey_patterns_for_stop(router_t *router, router_request_t *r
/* & journey_pattern_active_flags seems to provide about 14% increase
* in throughput
*/

if ((router->day_mask & jp_active_flags) &&
(req->mode & router->tdata->journey_patterns[journey_patterns[i_jp]].attributes) > 0) {
bitset_set (router->updated_journey_patterns, journey_patterns[i_jp]);
#ifdef RRRR_INFO
fprintf (stderr, " journey_pattenr running\n");
#endif
}
#endif
} while (i_jp);

#ifdef RRRR_FEATURE_REALTIME_EXPANDED
Expand Down Expand Up @@ -255,15 +262,27 @@ static void unflag_banned_journey_patterns (router_t *router, router_request_t *
}

static void initialize_banned_journey_patterns (router_t *router, router_request_t *req) {
uint32_t i_jp = router->tdata->n_journey_patterns;
uint8_t i_banned_jp = req->n_banned_journey_patterns;

bitset_black(router->banned_journey_patterns);

do {
calendar_t jp_active_flags;
i_jp--;
jp_active_flags = router->tdata->journey_pattern_active[i_jp];

if (! ( router->day_mask & jp_active_flags &&
req->mode & router->tdata->journey_patterns[i_jp].attributes)) {

This comment has been minimized.

Copy link
@koch-t

koch-t Dec 16, 2014

Author Owner

Could you check if i need another set of parantheses or this really means
router->day_mask & jp_active_flags AND req->mode & router->tdata->journey_patterns[i_jp].attributes)

/* Journey is invalid on selected days and/or attributes */
bitset_unset (router->banned_journey_patterns,i_jp);
}
} while (i_jp);

if (i_banned_jp == 0) return;
do {
i_banned_jp--;
bitset_unset (router->banned_journey_patterns,
req->banned_journey_patterns[i_banned_jp]);
bitset_unset (router->banned_journey_patterns,req->banned_journey_patterns[i_banned_jp]);
} while (i_banned_jp);
}
#else
Expand Down

0 comments on commit 7054231

Please sign in to comment.