Skip to content

Profile debug script which fetches a way from OSM#5908

Merged
akashihi merged 3 commits intoProject-OSRM:masterfrom
systemed:debug_way
Dec 21, 2020
Merged

Profile debug script which fetches a way from OSM#5908
akashihi merged 3 commits intoProject-OSRM:masterfrom
systemed:debug_way

Conversation

@systemed
Copy link
Copy Markdown
Member

Issue

When debugging profile issues (e.g. #5892), it's useful to be able to see instantly what the profile is calculating for a given way, without having to reprocess a whole OSM extract.

This short script fetches a way from the OSM API and runs the requested Lua profile over it, then prints the result:

$ lua5.1 debug_way.lua car 14672606
{ 
  highway = 'residential',
  maxspeed = '45 mph',
  name = 'E0770 Road',
  ['source:maxspeed'] = '45 in Blaine County unless otherwise posted.',
  ['tiger:cfcc'] = 'A41',
  ['tiger:county'] = 'Blaine, OK',
  ['tiger:name_base'] = 'E0770',
  ['tiger:name_type'] = 'Rd',
  ['tiger:reviewed'] = 'no' 
}
=>
{ 
  backward_classes = {},
  backward_mode = 1,
  backward_rate = 16.09,
  backward_speed = 57.924,
  duration = 0,
  forward_classes = {},
  forward_mode = 1,
  forward_rate = 16.09,
  forward_speed = 57.924,
  is_left_hand_driving = false,
  is_startpoint = true,
  name = 'E0770 Road',
  road_classification = { 
    may_be_ignored = false,
    road_priority_class = 10 
  } 
}

It uses the existing debug handler (tweaked to not error on the missing get_location_tag C++ method) and builds upon the example profile_debugger.lua script.

I use a similar script to this for cycle.travel and have found it enormously helpful in debugging profile issues.

Tasklist

Requirements / Relations

Required Lua libraries are listed in the comments at the top of the script.

Copy link
Copy Markdown
Contributor

@jcoupey jcoupey left a comment

Choose a reason for hiding this comment

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

Handy script indeed, just tested it.

--
-- You'll need to install luasec and xml2lua first:
-- > luarocks-5.1 install xml2lua
-- > luarocks-5.1 install luasec
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like luasec isn't really required? I got an error all right prior to installing xml2lua but nothing related to not having run luarocks install luasec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've rephrased the comment to note that you may have this already (my Ubuntu box and Mac didn't).

-- [may require admin privileges]
--
-- Then to test way 2606296 using the foot profile:
-- > lua5.1 debug_way.lua foot 2606296
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My system (Ubuntu) currently does not have lua5.1 installed but lua5.2 which is also accessible via the lua generic command. If the same apply across other systems, pointing to simply lua would make it more generic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess it applies not only for ubuntu, so indeed, this needs to be just lua

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No problem, changed (blame Homebrew for this one ;) ).

Copy link
Copy Markdown
Contributor

@akashihi akashihi left a comment

Choose a reason for hiding this comment

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

Please replace docs references to 5.1 with more generic references to lua

@systemed systemed requested a review from akashihi December 16, 2020 11:23
@akashihi akashihi merged commit dddf83d into Project-OSRM:master Dec 21, 2020
mjjbell pushed a commit to mjjbell/osrm-backend that referenced this pull request Jan 17, 2021
Profile debug script which fetches a way from OSM
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