nroi / flexo

a central pacman cache
MIT License
172 stars 10 forks source link

Mirror selection: Avoid unreliable mirrors #74

Open nroi opened 2 years ago

nroi commented 2 years ago

The official mirror endpoint (https://archlinux.org/mirrors/status/json/) provides the completion_pct property: If a status check hasn't succeeded in the past, the completion_pct is smaller than 1. We should use this information to avoid selecting unreliable mirrors.

Currently, we are already using the score attribute, which is calculated using the completion_pct and other attributes: As stated on https://archlinux.org/mirrors/status/:

Mirror Score: A very rough calculation for ranking mirrors. It is currently calculated as (hours delay + average duration + standard deviation) / completion percentage. Lower is better.

The problem is that this score does not punish unreliable mirrors as much as it should. For example, suppose two mirrors have the exact same values for hours delay, average duration and standard deviation, but one mirror has a completion percentage of 1, the other mirror has a completion percentage of 0.5. This means the less reliable mirror will only have a score twice as large as the more reliable mirror.