caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nils Becker <nils.becker@bioquant.uni-heidelberg.de>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>, becker.nils@gmx.net
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] using React for -- reactions
Date: Wed, 20 Aug 2014 11:11:18 +0200	[thread overview]
Message-ID: <53F46636.4070402@bioquant.uni-heidelberg.de> (raw)
In-Reply-To: <1B358C457E1445C0A76B9491809C4C6D@erratique.ch>

>> bottom line: can a React based simulation possibly compete with
>> manual, in-place update of arrays, let's say within a factor of 2?
>> if yes what do i need to pay attention to?
> 
> No idea. Basically you need to pay attention to the topology of your
> graph. 

one data point: i removed one linear dependency and saw 15% speedup, so
this seems to be the way to go.

the code was similar to this:

let signal_1 = S.merge f init_val {bunch of other signals} in
let signal_2 = S.map g signal_1

actually i'm not interested in signal_1 in itself. it is the result of a
list fold with f. its values are pairs that still contain an auxiliary
accumulator variable. in the second step i post-process this result to
give the meaningful signal_2. nothing else depends on signal_1.

i now got rid of signal_2 by putting the post-processing into the
downstream dependents of signal_1. this makes the structure of the
program a bit less nice since i now use the half-finished signals, but
it removes one trivial dependency. i think this is the cause of the speedup.

this is actually a general pattern i find myself using: a combinator
does not quite do all of the transformations i need, so i make another
signal/event directly downstream which completes the processing. another
example is

let evt_1 = E.select {bunch of events} (* not interested in evt_1 *)
let signal_2 = S.accum evt_1 init_val  (* except for making this *)

it now turns out this pattern is not really for free since it makes
dependency chains longer. it would be cool to have a way to 'contract'
these trivial links in the dependency graph. ie. to produce the result
of signal_2 directly, with only a single node in the graph. or to
'block' them together in the dependency resolution in some way. is there
already a way to do this that i missed?

n.

      parent reply	other threads:[~2014-08-20  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19  8:34 becker.nils
2014-08-19 12:27 ` Daniel Bünzli
2014-08-19 13:13   ` Nils Becker
2014-08-20  9:11   ` Nils Becker [this message]

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=53F46636.4070402@bioquant.uni-heidelberg.de \
    --to=nils.becker@bioquant.uni-heidelberg.de \
    --cc=becker.nils@gmx.net \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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).