Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

Ticket #14891 (closed enhancement: fixed)

Opened 8 months ago

Last modified 8 months ago

PATCH: use the fastest mirror in fetch phase

Reported by: jmr@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts base enhancements
Component: base Version: 1.7.0
Keywords: Cc: raimue@…
Port:

Description

Here's a patch which makes the fetch phase ping each of the candidate download sites, and then sort the list in ascending order of ping time. This is my first attempt at writing Tcl, so no doubt it could be done better, and I welcome any advice.

Some issues that need to be thought about:

  • We probably want to special-case some mirrors. We always want to try MacPorts svn last, and the primary site for each mirror group should be second-last.
  • Caching. Is it worth the effort? Maybe pinging every mirror every time is fine. When do we refresh cache entries?
  • User hints/overrides. If the user tells us that certain mirrors are good, we should always try them first when eligible.

Attachments

sortsites.diff (1.6 KB) - added by jmr@… 8 months ago.
sortsites2.diff (1.8 KB) - added by raimue@… 8 months ago.
sortsites3.diff (2.6 KB) - added by jmr@… 8 months ago.
sortsites4.diff (2.8 KB) - added by raimue@… 8 months ago.
sortsites4.2.diff (2.8 KB) - added by raimue@… 8 months ago.

Change History

Changed 8 months ago by wsiegrist@…

I tested with and without the patch on 2 random ports: less and php5.

less: the svn.macosforge.org sites won and were tried first, even though they dont have the files. You should probably exclude macosforge and macports sites from the ping test until we have mirroring going.

php5: it took longer to fetch because it waited up to 5s for each mirror it seems. Maybe try to find a winner with "-t1", then "-t5" to minimize the impact of downed mirrors.

Overall I like the idea though.

Changed 8 months ago by jmr@…

Changed 8 months ago by jmr@…

Updated the patch to try svn.macports.org last, ping with only one packet, and use a 1-second timeout in the interest of speed. Slow mirrors won't be sorted in quite the correct order, but I don't think that that's a real problem. Working mirrors that just don't respond to ping will go last in any case, but again, things should still generally be better with the patch than without.

It would be ideal to run all the pings in parallel, but I don't know how to do that.

Changed 8 months ago by raimue@…

Changed 8 months ago by raimue@…

Added 'sortsites2.diff‘; an updated version of the patch which avoids hardcoding 'svn.macports.org', but uses the fallback_mirror_list where this host actually comes from.

Changed 8 months ago by jmr@…

Updated: don't re-ping hosts that have already been pinged. Saves a lot of time in cases where hosts appear in the list several times.

Changed 8 months ago by jmr@…

Updated again: ping all hosts in parallel.

Changed 8 months ago by wsiegrist@…

Latest patch works well for me.

Changed 8 months ago by jmr@…

Changed 8 months ago by jmr@…

Updated: Recognise invalid hostnames like image_magick.veidrodis.com. (Sigh.) Check that the output from ping can be parsed as a number. Switched to using 3 ping packets and a 3-second timeout, since we effectively only have to wait for it once now that the pings run in parallel. Also simplified the code a bit.

Changed 8 months ago by raimue@…

Changed 8 months ago by raimue@…

Changed 8 months ago by raimue@…

Updated sortsites4.diff: If there is only one host (besides the fallbacks), don't ping or sort.

Changed 8 months ago by raimue@…

  • cc raimue@… added

This patch works just great. I encourage you to commit it, jmr!

Changed 8 months ago by jmr@…

  • status changed from new to closed
  • resolution set to fixed

Committed in r35748. Thanks for the help!

Note: See TracTickets for help on using tickets.