unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <mdjurfeldt@gmail.com>
Cc: Mikael Djurfeldt <djurfeldt@nada.kth.se>, guile-devel@gnu.org
Subject: Re: About 'futures'
Date: Tue, 8 Mar 2005 21:52:35 +0100	[thread overview]
Message-ID: <66e540fe05030812526a7ccb6f@mail.gmail.com> (raw)
In-Reply-To: <ljhdjmrp3y.fsf@troy.dt.e-technik.uni-dortmund.de>

On Tue, 08 Mar 2005 19:04:17 +0100, Marius Vollmer
<marius.vollmer@uni-dortmund.de> wrote:
> what is the difference between
> 
>     (join-thread (begin-thread (foo)))
> 
> and
> 
>     (future-ref (future (foo)))

The first construct is guaranteed to start a new OS thread with its
own, complete, dynamic context.  The indended usage pattern is an
application divided into a number of threads handling different tasks.
The implementation is optimized for the completeness of the
environment provided in the thread rather than, e.g., startup time.

The second is a lightweight mechanism intended for fast, small-scale,
parallelism, such as in the `letpar' or 'par-map' constructs which
evaluate its component expressions in parallel. The implementation is
optimized for quick start and delivery of the result rather than
providing a complete context rooted in a new OS thread. The current
implementation caches a number of "workers", so rather than spawning a
new thread, `future' simply implies signalling a condition variable.
(The current implementation is not complete since the dynamic context
is not re-initialized for each evaluation in a worker thread. In order
to complete the implementation one needs to define what "dynamic
context" includes in this case. The aim is that it should be minimal.)

> I am thinking about implementing futures as just
> 
>     (define-macro (future exp) `(begin-thread ,exp))
>     (define future-ref join-thread)
> 
> Would that make sense?

I don't think so for obvious reasons.  It would not make sense to
spawn new pthreads for the kind of usage patterns for which futures
are intended. In my opinion it's better to scrap futures entirely than
to provide the suggested implementation above.

But I would surely miss them. I have used these parallel language
constructs to make computations go faster on an SMP machine. It makes
beautiful sense when the subexpressions of a letpar are matrix
computations with operations implemented on the C level. Note also
that futures, by their nature, necessarily needs to be maintained
together with the guile-core rather than being provided by a separate
package.

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2005-03-08 20:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-08 18:04 About 'futures' Marius Vollmer
2005-03-08 20:52 ` Mikael Djurfeldt [this message]
2005-03-08 23:35   ` Kevin Ryde
2005-03-09 15:15   ` Marius Vollmer
2005-03-09 19:02     ` Marius Vollmer
2005-03-09 19:50       ` Rob Browning
2005-03-08 21:37 ` Rob Browning
2005-03-09 15:17   ` Marius Vollmer

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=66e540fe05030812526a7ccb6f@mail.gmail.com \
    --to=mdjurfeldt@gmail.com \
    --cc=djurfeldt@nada.kth.se \
    --cc=guile-devel@gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).