Browse thread
Asynchronous IO programming in OCaml
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jérémie Dimino <jeremie@d...> |
| Subject: | Re: [Caml-list] Asynchronous IO programming in OCaml |
On Wed, Oct 27, 2010 at 11:33:51AM +0200, Goswin von Brederlow wrote: > You aren't doing any multithreading. You are creating a thread and > waiting for the thread to finish its read before strating a second. > There are never ever 2 reads running in parallel. So all you do is add > thread creation and destruction for every read to your first example. Yes, i know that. The idea was just to show the overhead of context switches. > You should start multiple threads and let them read from different > offsets (use pread) and only once they are all started join them all > again. Sure, but doing this directly in Lwt raises other problems: - This means prefetching a large part of the file into the program memory. - The kernel already prefetches files from the disk, so most of the time this is just a memory copy in parallel... - How many threads do we launch in parallel ? This depends on the overhead of context switching between threads, which can not be determined at runtime. I think that the solution with mincore + mmap is better because it uses threads only when really needed. Jérémie