[bittorrent] Introductory/endgame algorithms
Olaf van der Spek
olafvdspek at gmail.com
Thu Sep 29 03:38:02 EDT 2005
On 9/29/05, Elliott Mitchell <ehem at m5p.com> wrote:
> >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?).
I think it's the other way around, the common case being multiple files.
More information about the BitTorrent