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

Replace Luabind with Sol2 #3382

Merged
merged 5 commits into from
Dec 15, 2016
Merged

Replace Luabind with Sol2 #3382

merged 5 commits into from
Dec 15, 2016

Conversation

karenzshea
Copy link
Contributor

@karenzshea karenzshea commented Nov 30, 2016

Issue

#3013

To quote @daniel-j-h

We're running on Luabind and it's a constant pain not only for us but also for users. As soon as we manage to port our code we will switch over to sol2 and never look back.

Tasklist

  • Investigate test failures
  • Figure out if returning an empty string instead of null is backwards incompatible
  • Port forward any recent changes to scripting_environment_lua.cpp
  • Check feature parity wrt. what we bind to Lua. Go over old / new impl. and check off.
  • Add to update-dependencies script
  • Check compatibility with lua versions
  • update relevant Wiki pages I have a list of pages to update once pr has been merged
  • add regression / cucumber cases (see docs/testing.md)
  • review
  • adjust for comments

Requirements / Relations

This is a pre-MLD task.


// TODO: do we want this?
//"get_nodes",
//&osmium::Way::nodes);
Copy link
Member

Choose a reason for hiding this comment

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

Yeah we need to have a 1:1 feature parity with our old Luabind code. Please go over both impls. and check this.

(Sorry that was me being lazy not registering all functions in the initial pass)

context.state.new_type<RasterDatum>("RasterDatum",
"datum", &RasterDatum::datum,
"invalid_data", &RasterDatum::get_invalid);
*/
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 before we can merge this.

{
auto get_value_by_key(const char *key, const char *default_value = nullptr) const
{
return way.get_value_by_key(key, default_value);
Copy link
Contributor

Choose a reason for hiding this comment

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

note the recent change to return null instead of empty tags

@@ -91,6 +91,7 @@ endif()

include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/)
Copy link
Member

Choose a reason for hiding this comment

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

Hm can you vendor the package at third_party/sol2/ add this path here and then

third_party/sol2/sol2/sol.hpp
                ^ includedir points here

so the user can still do include <sol2/sol.hpp>

Copy link
Member

Choose a reason for hiding this comment

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

also below: can you rebase on master, all access restricted tags should be gone by now - if not please ping me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already rebased, which is how I picked up on the missing sol directory includes. I'll update how the sol header is saved and update in the cmakelists now.

@@ -46,6 +46,7 @@ struct ExtractionWay
roundabout = false;
circular = false;
is_startpoint = true;
ignore_in_grid = false;
Copy link

Choose a reason for hiding this comment

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

Could this be left-over code? I wanted to check for it but could not find it in the remaining parts of the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this field. Sol was erroring in places where we set this property in bicycle/foot profiles but hadn't registered a corresponding field in the bindings. I'm not sure how luabind handled this before.

Copy link

Choose a reason for hiding this comment

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

I did some digging. Seems the profiles are out of date. That flag was removed in faa880d

Copy link

@MoKob MoKob Dec 5, 2016

Choose a reason for hiding this comment

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

Capturing from chat: Next actions:

  • remove dead flag (ignore_in_grid) from foot/bicycle profile
  • remove bindings for (ignore_in_grid)
  • remove ignore_in_grid from extraction_way.hpp

@karenzshea karenzshea force-pushed the bye-luabind branch 4 times, most recently from e715643 to 3c7834f Compare December 6, 2016 15:58
@karenzshea
Copy link
Contributor Author

I checked compatibility with Lua 5.1 and 5.2 by building osrm with both versions and running tests. They check out OK; if there's any further testing I should do, lmk @MoKob @daniel-j-h

@karenzshea
Copy link
Contributor Author

@daniel-j-h @TheMarex review?

Copy link
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

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

Almost read for merging once we pushed 5.5 out. 🎉 👋 luabind. We should also mark https://github.com/mapbox/luabind as deprecated since we won't support this anymore.

@@ -282,15 +282,15 @@ endif()

# Configuring compilers
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics -ftemplate-depth=1024")
Copy link
Member

Choose a reason for hiding this comment

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

😿

Copy link
Member

Choose a reason for hiding this comment

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

clang has a default limit of 256, gcc has 1024 - this is fine 👍

#define SCRIPTING_ENVIRONMENT_LUA_HPP

#include "extractor/scripting_environment.hpp"
#ifndef SCRIPTING_ENVIRONMENT_SOL2_HPP
Copy link
Member

Choose a reason for hiding this comment

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

Hm why did we rename this file? Sure the library that we use for executing lua changed but this is still for executing lua code.

Copy link
Member

Choose a reason for hiding this comment

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

I did this back a month ago when I was experimenting with sol2 and still had the luabind files around - this can change now

}
}

void Sol2ScriptingContext::processNode(const osmium::Node &node, ExtractionNode &result)
Copy link
Member

Choose a reason for hiding this comment

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

Naming convention would be ProcessNode.

node_function(node, result);
}

void Sol2ScriptingContext::processWay(const osmium::Way &way, ExtractionWay &result)
Copy link
Member

Choose a reason for hiding this comment

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

Naming convention would be ProcessWay.

@@ -473,6 +465,33 @@ else()
find_package(GDAL)
endif()

FIND_PACKAGE(Lua 5.2 EXACT)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can now simplify all this logic down to find_package(Lua 5.1) which will look for lua 5.1+. Sol seems to have a good support for all lua versions, unlike luabind.

Copy link
Member

Choose a reason for hiding this comment

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

The check here was because of the Lua 5.3 memory issue and not specifically for Luabind - until we confirm the Lua 5.3 memory issues are gone simply by using sol we should keep it.

@@ -96,6 +96,7 @@ struct ExtractionWay
bool roundabout;
bool circular;
bool is_startpoint;
bool ignore_in_grid;
Copy link
Member

Choose a reason for hiding this comment

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

This seems like an accidental change.

Copy link
Member

Choose a reason for hiding this comment

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

yes this has to go - not only here but also in the profiles and the bindings, see #3382 (review)

@karenzshea karenzshea force-pushed the bye-luabind branch 2 times, most recently from ed88ad5 to 945f1ce Compare December 7, 2016 14:13
@daniel-j-h
Copy link
Member

Windows build are failing:

C:\projects\osrm\third_party\sol2\sol2/sol.hpp(771): fatal error C1083: Cannot open include file: 'lua.hpp': No such file or directory [C:\projects\osrm\build\EXTRACTOR.vcxproj]

Seems like the C++ lua.hpp wrapper can't be found on Windows. cc @BergWerkGIS

@karenzshea
Copy link
Contributor Author

Timing the switch:

  • ran extraction the germany geofabrik extract
  • r3.8xlarge machine, 32 cores
branch extraction time parsing time
bye-luabind real 15m41.392s, user 39m24.131s, sys 16m7.835s 130.264
master real 16m25.099s, user 58m34.169s, sys 28m56.980s 196.322s

@daniel-j-h
Copy link
Member

These are great numbers and will lift some pressure from the guidance code!

(Unrelated to this PR: the next step would be to instead of context switching for every node or way, we switch on a nodes-chunk and ways-chunk basis => #1777)

@wilhelmberg
Copy link
Contributor

@daniel-j-h where is lua.hpp coming from on other platforms?
On Windows we clone https://github.com/LuaDist/lua
The only one I could find in this repo is https://github.com/LuaDist/lua/blob/lua-5.1/etc/lua.hpp
But we don't include it - would it be the one we need?

@daniel-j-h
Copy link
Member

Yes this looks like the file we need. It's just setting up the includes for the C name mangling.

@daniel-j-h daniel-j-h mentioned this pull request Dec 14, 2016
@wilhelmberg
Copy link
Contributor

@daniel-j-h could you try again - I've updated and rebuilt that binary deps package.

lua.hpp is now in osrm-deps\libs\include:

image

@daniel-j-h
Copy link
Member

Rebased against master and force-pushed. Let's see if Appveyor is happy with it now. cc @karenzshea

@daniel-j-h
Copy link
Member

@BergWerkGIS thanks, this resolved it. Ready for merge now! 🎉

@TheMarex TheMarex merged commit 68e3888 into master Dec 15, 2016
@TheMarex TheMarex deleted the bye-luabind branch December 15, 2016 09:55
@daniel-j-h
Copy link
Member

It's gone, Luabind is gone - I can't believe it! :)

Updating the Wiki pages now.

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.

7 participants