[bittorrent] Introductory/endgame algorithms

Elliott Mitchell ehem at m5p.com
Thu Sep 29 03:22:36 EDT 2005


>From: Olaf van der Spek <olafvdspek at gmail.com>
> On 9/29/05, Elliott Mitchell <ehem at m5p.com> wrote:
> > Bad idea to do it that way. I doubt most OSes do read-ahead on mmap()ed
> > files, and for what BitTorrent is doing readahead is quite important.
> > Your best bet is use pread()/readv() on whole pieces when the first block
> > is requested, and ensure your buffer is page-aligned
> > (sysconf(_SC_PAGESIZE)).
> 
> Doesn't that also require the read offset to be aligned?

Yes. Given that most torrents use 256KB or larger pieces though, no
systems I know of have page sizes larger than that and all are some
factor of 256KB. Most use 4KB pages, SunOS on SPARC uses 8KB pages. No
problem, all pieces will be page aligned. In fact all block requests
should be page aligned. At least with torrents containing large single
files (the common case I believe?).


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         EHeM at gremlin.m5p.com PGP 8881EF59         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
    \___\_|_/82 04 A1 3C C7 B1 37 2A*E3 6E 84 DA 97 4C 40 E6\_|_/___/





More information about the BitTorrent mailing list