Refactor code generation using quote, syn and rayon.#58
Refactor code generation using quote, syn and rayon.#58jerry73204 wants to merge 7 commits intosequenceplanner:masterfrom
Conversation
3baaa97 to
fa703cb
Compare
fa703cb to
b659c0d
Compare
b659c0d to
76c8af9
Compare
|
The |
|
Great work @jerry73204 . As discussed in #50 lets go ahead with this pr. I have just rebased this on top of #51 and pushed to master, so it will be easier to make new PRs from here in case @JiangengDong wants to contribute. I also fixed up the last commit with a refresh of the the docs with just the standard ros install to make it pass CI. |
|
@m-dahl Thanks you merge my work. Just a reminder that the generated bindings in this PR are huge. That's because I installed almost everything on my laptop. It will cause a very long compile time (~5 minutes) for the doc-only feature. Could you please re-generate the bindings for docs.rs using this IDL_PACKAGE_FILTER? The package list comes from the official ROS 2 doc here. export IDL_PACKAGE_FILTER='action_msgs;diagnostic_msgs;geometry_msgs;lifecycle_msgs;map_msgs;move_base_msgs;nav_msgs;pendulum_msgs;rosgraph_msgs;sensor_msgs;shape_msgs;statistics_msgs;std_msgs;stereo_msgs;test_msgs;tf2_geometry_msgs;tf2_msgs;trajectory_msgs;unique_identifier_msgs;visualization_msgs'I use this procedure to refresh the bindings. rm -rf target
rm r2r*/bindings/*
cargo build --features save-bindgen
cargo build --features doc-only # make sure the bindings work |
|
Yes I noticed it was huge so I modified your last commit before pushing. I refreshed them using humble-desktop + test_msgs. Perhaps we should make a script for refreshing using that standard package list? |
Refresh bindings with new codegen by #58
This work thoroughly rewrites the code generation parts of this project. With the help of
synandquote, it processes code in tokens instead of string manipulation. It applies several tricks to speed up the codegen process, including parallelism and bindgen allowlist. It fixes thedoc-onlyfeature so that it can create API docs without ROS installed.quoteandsyncrates to parse the bindgen code into tokens instead of string manipulation. The approach promises error-free code generation. It fixes a known bug that it did not parse array typed fields[T; N]correctly.rayonto speed up the code generation process. It enablesbuild.rsto process manyRosMsgin parallel on a multi-core machine, and now thebuild.rscan finish in a few seconds.phf::Mapto speed up the lookup process in runtime. The changes are made inUntypedServiceSupport::new_from(),INTROSPECTION_FNS,andCONSTANTS_MAP.bindgento speed up the codegen process. Though it's still the slowest part overall, it still saves a few minutes.doc-onlyfeature to produce API docs without actually linking ROS dynamic link libraries.