caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bardur Arantsson <spam@scientician.net>
To: caml-list@inria.fr
Subject: Re: Help interfacing with C
Date: Sat, 19 Aug 2006 00:24:40 +0200	[thread overview]
Message-ID: <ec5en8$4eg$1@sea.gmane.org> (raw)
In-Reply-To: <aee06c9e0608181433x31978500k8c07e083cbec8742@mail.gmail.com>

Nathaniel Gray wrote:
> On 8/16/06, Bardur Arantsson <spam@scientician.net> wrote:
>> Nathaniel Gray wrote:
>> > Hi folks,
>> [--snip--]
> 
> Thanks, but this doesn't really help.  Perhaps I should say what I'm
> trying to accomplish instead of trying to let the types speak for me.
> The point is that when you select on a list of file descriptors
> there's a very good chance that you don't *only* care that file
> descriptor f is ready, you also have some ocaml data structure
> associated with f that you want to use with it in some way.  For
> example, you probably have a string to write or a buffer to read into.
> 
> The current API is sort of a minimal translation of the select system
> call to OCaml, which is a good starting point, but not great IMHO.  In
> order to match up each file descriptor to its data you have to scan
> the output fd list yet again, after it's already been done once at the
> C level, and since you don't know how/if it's sorted you end up with
> unsatisfying time complexity for the whole thing.  It's not critical,
> since the lists are small, but it hardly brings a smile to your face.
> 
> On the other hand, imagine a select2 that takes lists of (fd, 'a)
> pairs and returns the same.  The results become incredibly easy to
> handle, with no scanning necessary.  You probably just List.iter a
> simple read/write function over the result and you're done.
> 

Have you tried to benchmark the naive implementation(*) versus a "bare" 
Unix.select? I shouldn't think you a little bit extra of scanning the 
list which is O(n) in the number of _active_ file descriptors matters 
with all the O(MAX_FD) stuff that's going on in select(). I would expect 
most of the time to be spent doing the actual system call.

(*) That is, an implementation which puts (fd, associated value) in a 
hashtable indexed by the file_descr and does the scanning after doing 
the Unix.select.

Cheers,

-- 
Bardur Arantsson
<bardurREMOVE@THISscientician.net>

- This is supposed to be a happy occasion. Let's not *bicker* and
*argue* about who killed who.
                                 'Monty Python and the Holy Grail'


  reply	other threads:[~2006-08-18 22:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-16 19:34 Nathaniel Gray
2006-08-17  3:49 ` [Caml-list] " malc
2006-08-18 21:00   ` Nathaniel Gray
2006-08-17  5:56 ` Bardur Arantsson
2006-08-18  7:10   ` [Caml-list] " Olivier Andrieu
2006-08-18 15:50     ` Bardur Arantsson
2006-08-18 21:33   ` [Caml-list] " Nathaniel Gray
2006-08-18 22:24     ` Bardur Arantsson [this message]
2006-08-19  0:33       ` Nathaniel Gray
2006-08-19  6:03         ` Bardur Arantsson
2006-08-21 22:45           ` [Caml-list] " Nathaniel Gray
2006-08-19  8:30         ` Olivier Andrieu
2006-08-21 22:35           ` Nathaniel Gray
2006-08-19  9:03     ` Richard Jones
2006-08-19  9:41       ` skaller
2006-08-18  8:46 ` [Caml-list] " Damien Doligez
2006-08-18 20:09   ` Nathaniel Gray
2006-08-23 23:36 ` Nathaniel Gray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ec5en8$4eg$1@sea.gmane.org' \
    --to=spam@scientician.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).