livepeer / go-livepeer

Official Go implementation of the Livepeer protocol
http://livepeer.org
MIT License
538 stars 168 forks source link

feat(ai): enhance orchestrator selection by incorporating latency #3043

Closed rickstaa closed 4 months ago

rickstaa commented 4 months ago

What does this pull request do? Explain your changes. (required)

This pull request, done in collaboration with @ad-astra-video, introduces latency consideration into the orchestrator selection process, addressing two key issues. Firstly, it resolves a minor bug where the algorithm consistently selected known orchestrators due to a condition that never evaluated to true (see this condition). Secondly, this change ensures that, once all orchestrators have been evaluated, the one with the fastest response time for a specific job is chosen. While the current method for calculating latency is somewhat basic, it sets the foundation for more sophisticated enhancements in the future.

Specific updates (required)

How did you test each of these updates (required)

Does this pull request close any open issues?

https://linear.app/livepeer-ai-spe/issue/LIV-302/selection-algorithm-sticks-to-known-sessions-after-one-has-been-found

Remarks

The latency calculation formula is a bit naive but it seems to work for the current piplines it howver might be needed to improved when schedulers or other pipeline tools are added.

[!IMPORTANT] It's crucial to highlight that this action effectively suspends the stake-based selection formula once latencies for all nodes have been identified. To enhance the process, we could consider modifying the MinLSSelector to prioritize the fastest 30% and implement a weight-based selection algorithm accordingly.

Checklist:

rickstaa commented 4 months ago

@yondonfu, I've tested this pull request and found that it significantly improves the situation. However, please feel free to provide feedback if this doesn't align with your expectations.

https://github.com/livepeer/go-livepeer/blob/f583d932172457745bd2a368da8b25d3cbb49ee9/server/ai_session.go#L125

The current implementation isn't yet perfect, as it suspends the stake-based selection formula once latencies for all orchestrators are known. To address this, we might enhance the process by modifying the MinLSSelector to prioritize the fastest 30% and implement a weight-based selection algorithm accordingly. For more details, refer to the discussion at: update-minlsselector-to-select-known-os-based-on-regular-selection.