caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: caml-list@inria.fr
Subject: Re: [Caml-list] ocaml-3.05: a performance experience
Date: Tue, 06 Aug 2002 13:22:02 +1000	[thread overview]
Message-ID: <3D4F40DA.5040006@ozemail.com.au> (raw)
In-Reply-To: <021e01c23c9c$86d0c9b0$240f2744@cc1003186f>

Mike Lin wrote:

>>I'm intrigued by the relationship between these two parsers. In
>>
> particular,
> 
>>note that my Felix compiler takes 'pull' code, and automatically
>>translates it
>>to the much more efficient 'push' model: ie. it switches the client/server
>>relationship around, a process I call control inversion.
>>
> 
> I'm just curious if you could elaborate on in what respect a push parser is
> "much more efficient"? 


Blocking IO using OS resources is very slow -- O(log N) is good.
User space dispatching is typically very fast: O(1) [using a hashtable]

So if you're parsing XML being read over the internet,
the push technology is superior -- if you can bypass
the high level socket interface (which is non-trivial :-(

>From my experience pull parsers tend to be easier to
> use because they don't impose an event-driven model on the driver program,


	Absolutely! That is why Felix exists. To allow one to
write 'pull' code, which does blocking reads of data, but have the
code translated to 'push' code, where a thread is resumed by a
dispatcher when the data is available.

	For some applications like telephony, where the number
of connections is rather large, event driven code is the ONLY option.
Unix OS are typically incapable of handling millions of threads, a user
space dispatcher has no trouble at all, even on a small Linux PC.
The reason is: client level code 'knows' the encoding of messages
and can sort out where to send it much faster than any generic
OS facilities can: OS schedulers are designed to run arbitrary
mixtures of programs, not millions of threads of the same application.


> and also it is trivial to build a push parser on top of a pull parser.


	Yep. Just write a dispatch loop :-)


-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2002-08-06  3:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-02  3:33 Alexander V. Voinov
2002-08-03 12:33 ` Gerd Stolpmann
2002-08-03 17:27   ` [Caml-list] OCAMLRUNPARAM=b David Fox
2002-08-04  2:50   ` [Caml-list] ocaml-3.05: a performance experience Alexander V. Voinov
2002-08-04 20:45     ` Gerd Stolpmann
2002-08-05 15:18       ` John Max Skaller
2002-08-05 16:24         ` Mike Lin
2002-08-05 16:53           ` Alexander V.Voinov
2002-08-06  3:22           ` John Max Skaller [this message]
2002-08-06 13:24             ` Mike Lin
2002-08-06 11:10           ` Noel Welsh
2002-08-06 12:56             ` Andreas Rossberg
2002-08-04 18:06 Damien Doligez

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=3D4F40DA.5040006@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --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).