fzi-forschungszentrum-informatik / Lanelet2

Map handling framework for automated driving
BSD 3-Clause "New" or "Revised" License
800 stars 327 forks source link

[Feature] Python pickle support for use in multiprocessing #199

Closed odel4y closed 1 year ago

odel4y commented 3 years ago

Hi!

IMO many use-cases for Lanelet2 in Python would greatly benefit in performance from using multiple CPU cores. Python offers, amongst others, the multiprocessing module for this task to work around the Python GIL. A requirement to share Python objects between multiple processes is for them to support the Pickle serialization protocol. As Lanelet2's Python interface is built on interfacing its C++ class definitions, this support is currently not included. Boost.Python however offers methods to implement Pickle support explicitly.

Do you have any plans to support Pickle serialization or have had thoughts about that topic in the past? I can currently not quite grasp the workload that an implementation for the Basic Lanelet2 classes would require.

Thanks!

poggenhans commented 3 years ago

No plans to support it, but always happy about PRs. I guess one could do a low-level pickle approach by implementing this at least for LaneletMap objects and internally use lanelet2_ios binary serialization backend and return the result to pickle as a bytestring. More than that would be messy and work-intensive because pickle would have to follow all references (members of lanelets, regulatory elements referenced by lanelets, lanelets referenced by these these regulatory elements, ...).

Since Lanelet2 doesn't use the interpreter, lanelet2 objects are not affected by the GIL. But making use this would require us to release the lock on every python api call, or at least on heavy tasks. And that wouldn't help for modules like multiprocessing.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. Is this issue still work in progress? If yes, mark it as "WIP" or comment, otherwise it will be closed in 30 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 30 days with no activity.