unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Chris Vine <vine35792468@gmail.com>
To: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Limiting parallelism using futures, parallel forms and fibers
Date: Wed, 8 Jan 2020 11:44:02 +0000	[thread overview]
Message-ID: <20200108114402.2cabbd011c52456a73a2fca8@gmail.com> (raw)
In-Reply-To: <04cb0461-18a1-ef17-4db7-2475c7c806e6@posteo.de>

On Wed, 8 Jan 2020 08:56:11 +0100
Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> wrote:
[snip]
> So my questions are:
> 
> - Is there a default / recommended way to limit parallelism for
> recursive calls to parallel forms?
> 
> - Is there a better way than a global counter with locking, to limit the
> number of futures created during recursive calls? I would dislike very
> much to have to do something like global state + mutex.
> 
> - What do you recommend in general to solve this?

I think you have it wrong, and that futures use a global queue and a
global set of worker threads.  I don't see how futures could work
without at least a global set of worker threads.  Have a look at the
futures source code.

If you want more control over the thread pool than guile's futures
provide, you could consider something like this:
https://github.com/ChrisVine/guile-a-sync2/blob/master/a-sync/thread-pool.scm
But then you would have to make your own futures if you want a graph
of futures rather than a graph of coroutines (which is what you would
get if you use the associated event loop).

The main thing is to get the parallel algorithm right, which can be
tricky.



  parent reply	other threads:[~2020-01-08 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-08  7:56 Limiting parallelism using futures, parallel forms and fibers Zelphir Kaltstahl
2020-01-08  8:11 ` Linus Björnstam
2020-01-09 23:27   ` Zelphir Kaltstahl
2020-01-08 11:44 ` Chris Vine [this message]
2020-01-10  0:43   ` Zelphir Kaltstahl
2020-01-10 16:08     ` Chris Vine

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=20200108114402.2cabbd011c52456a73a2fca8@gmail.com \
    --to=vine35792468@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=zelphirkaltstahl@posteo.de \
    /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).