Add scheduling policy and improve threading and synchronization#954
Add scheduling policy and improve threading and synchronization#954helloyongyang merged 2 commits intoModelTC:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
This pull request significantly refactors the data transfer and threading logic in the
DataManagerclass inlightx2v/disagg/conn.pyto improve thread safety, resource management, and scalability. The changes introduce a global transfer thread (instead of per-room transfer threads), per-room ZeroMQ sockets, and improved locking for shared state. The code is now better structured for concurrent operations and easier resource cleanup.Key changes include:
Threading and Synchronization Improvements
DataManager, replacing per-room transfer threads. This thread is controlled by newtransfer_eventandtransfer_stop_eventattributes, and is started only for relevant disaggregation phases/modes. ([lightx2v/disagg/conn.pyR87-L127](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R87-L127))pool_lockto synchronize access to shared pools (request_pool,request_status,waiting_pool), ensuring thread safety during concurrent operations. ([[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R87-L127),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R470),[[3]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L464-R483),[[4]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R496))ZeroMQ Socket Management
server_socketwith per-room sockets managed in the newroom_socketsdictionary. Added helper methods to create, bind, and close sockets for each room, enabling independent communication channels per room and preventing port conflicts. ([[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R87-L127),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R253-L190))[[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L238-R330),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L251-R340),[[3]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L346-R400),[[4]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L359-R410),[[5]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R426-R451))Resource Cleanup and API Changes
releasemethod to clean up all threads, events, sockets, and data pointers across all rooms, ensuring a clean shutdown. The old per-roomreleaseis renamed toremove. ([[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L136-R186),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R210-R240))end_room_threadsto avoid resource leaks. ([lightx2v/disagg/conn.pyR253-L190](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R253-L190))Port Calculation and Addressing
room * 10offset, preventing port collisions when multiple rooms are used simultaneously. Also updated status synchronization to use the new port scheme. ([[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L228-R318),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L238-R330),[[3]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L346-R400),[[4]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L517-R534))Minor API and Logic Adjustments
DataSenderandDataReceiverinitialization and removed unused arguments. ([lightx2v/disagg/conn.pyL496-R513](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7L496-R513))[[1]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R87-L127),[[2]](https://github.com/ModelTC/LightX2V/pull/954/files#diff-a5e5778ac7adc9b8f2c175153e932db47158abebba325b47298001bc80e89ba7R253-L190))New Features
These changes collectively make the data transfer subsystem more robust, scalable, and maintainable.