Skip to content

Release the GVL during routing model setup - #87

Open
erickreutz wants to merge 1 commit into
ankane:masterfrom
lugg:eric/upstream-routing-setup-gvl
Open

Release the GVL during routing model setup#87
erickreutz wants to merge 1 commit into
ankane:masterfrom
lugg:eric/upstream-routing-setup-gvl

Conversation

@erickreutz

Copy link
Copy Markdown
Contributor

RoutingModel#close_model and #read_assignment_from_routes can spend significant time in native OR-Tools code, but unlike the existing solve wrappers, they currently hold Ruby's GVL for the entire call. This adds callback-aware wrappers that release the GVL during those operations when the routing model uses only native callbacks.

The safety boundary matches the solve path: models with Ruby transit callbacks retain the GVL, while native vector and matrix callbacks allow other Ruby threads to run. Route arrays are converted to owned C++ values before the GVL is released, and returned assignments are wrapped after Ruby execution resumes. The raw callback, solve, close, and restoration entry points are private so callers cannot bypass the callback gate.

The coverage exercises Ruby thread progress during both native calls, callback gating and exceptions, result parity, route conversion ownership, overlapping reads on separate models, and assignment lifetime. Existing routing results and callback behavior are unchanged.

Allow Ruby threads to keep running while callback-free routing models close and restore route assignments. Keep the GVL when Ruby transit callbacks may execute.
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.

1 participant