Skip to content

Reversing flags is expensive #728

Closed
Closed

Description

@karussell

When reversing the flags this is an expensive operation as also flag encoders that are not used for one specific traversal have to be properly swapped. Instead we could define one bit (e.g. first) which we use as indication for "forward storage" or "reverse storage", then on access of direction dependent properties like speed we can access the bit ranges dependent on this bit0:

class SomeFlagEncoder {...
 double getSpeed(flags) {
  if(isBit0Set(flags)) // if bit0 is 1 this defines 'forward'
     return forwardSpeedEncoder.getDoubleValue(flags);
  return reverseSpeedEncoder.getDoubleValue(flags);
}}

This way we can reduce the whole EncodingManager.reverseFlags method to one bit operation flipping the first bit, avoiding the loop and avoiding all swap operations (i.e. unrelated and even related). But introducing the isBit0Set for all direction dependent properties.

We could even avoid to store the direction with this one bit. Instead we could use the nodeA and nodeB as direction indication (e.g. nodeA>nodeB defines as 'forward') and store the flags accordingly. The only problem then would be that one would need to create the flags either in forward or in backward direction dependent on this low level storage which would be too ugly or we still need one potential reverseFlags call at least at writing time. Also the bit0 solution is edge independent and would work without #472.

Take into account shortcuts of CHGraph. See EdgeAccess.reverseFlags where we swap the two accessibility bits and now would need to read the forward&backward property dependent on bit0

Activity

  1. karussell commented on Feb 19, 2019

    @karussell
    MemberAuthor

    Fixed via #1447

  2. added this to the 0.12 milestone on Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions