unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Cc: Bill Schottstaedt <bil@ccrma.stanford.edu>, guile-devel@gnu.org
Subject: Re: scm_i_fraction_reduce thread safety
Date: Sat, 13 Dec 2003 09:23:40 +1000	[thread overview]
Message-ID: <87wu91mxhf.fsf@zip.com.au> (raw)
In-Reply-To: 1071170342.1217.60.camel@flare

Bill Schottstaedt <bil@ccrma.Stanford.EDU> writes:
>
> I'd vote for a lock,

I guess everywhere inspecting the parts of a fraction would need to
acquire and release such a lock.  Perhaps a macro that did that and
delivered out the parts could stop it being too awful when coding.

> if it's really an issue.

Unfortunately I believe it is, in the new-style free-running
concurrent posix threads.  It'll be one of those threading things that
might almost never actually cause a problem, but alas is not right.

> On the need for reduction, I wonder how much of that
> notoriety is due to Knuth -- his discussion of this
> was in a slightly artificial context, and I've been
> intending for a long time to check some "real-world"
> situation.

I guess +, -, *, / will keep increasing num and/or den (though perhaps
with some cancellation in the num for + and -), unless steps are taken
at some point.

> (I think it's less of a problem than calling gcd all the time).

The claim in gmp (without anything actual to cite :-), is that because
gcd is O(N^2) it's better to do a couple of smaller one's sooner than
to allow a product to accumulate and do a big one later.

Of course if one knows or suspects not much cancellation will be
possible in a given algorithm, then all theories about automated
reductions go out the window.  A general purpose fraction type is
probably not the tool for the job in that case.


Carl Witty <cwitty@newtonlabs.com> writes:
>
> I think that one way to avoid arbitrarily-bad behavior is to reduce only
> if the numerator or denominator is "sufficiently large" (I think this is
> at most a constant factor worse than always reducing).

mpz_t allocated memory could be counted towards the mtrigger, to
provoke a gc when big numbers are using up memory.  That's probably a
good idea anyway.  The gc could nose around and attempt to reduce
likely looking big fractions.


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


  parent reply	other threads:[~2003-12-12 23:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-11 11:43 scm_i_fraction_reduce thread safety Bill Schottstaedt
2003-12-11 19:19 ` Carl Witty
2003-12-12 12:11   ` Bill Schottstaedt
2003-12-12 15:04   ` Paul Jarc
2003-12-12 23:23   ` Kevin Ryde [this message]
2004-01-10 22:38     ` Marius Vollmer
2004-01-10 23:29       ` Kevin Ryde
2004-01-11  1:31         ` Marius Vollmer
2004-01-12  0:51           ` Kevin Ryde
2004-01-12  5:22             ` Richard Todd
2004-01-14 21:09               ` Kevin Ryde
2004-01-21  0:03               ` Marius Vollmer
2004-01-21  0:00             ` Marius Vollmer
2004-01-21  3:11               ` Carl Witty
2004-01-21 21:06                 ` Marius Vollmer
2004-01-27 22:15                 ` Dirk Herrmann
2004-01-27 23:24                   ` Rob Browning
2004-01-29 19:35                     ` Marius Vollmer
2004-01-29 20:32                       ` Rob Browning
2004-01-30 14:45                       ` Mikael Djurfeldt
2004-02-01 18:49                         ` Andy Wingo
  -- strict thread matches above, loose matches on Subject: below --
2003-12-09 20:39 Kevin Ryde

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=87wu91mxhf.fsf@zip.com.au \
    --to=user42@zip.com.au \
    --cc=bil@ccrma.stanford.edu \
    --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).