caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Thomas Fischbacher <Thomas.Fischbacher@Physik.Uni-Muenchen.DE>
To: Eijiro Sumii <eijiro_sumii@anet.ne.jp>
Cc: caml-list@inria.fr, sumii@saul.cis.upenn.edu
Subject: Re: [Caml-list] how to "disable" GC?
Date: Sun, 13 Mar 2005 13:52:55 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.61.0503131341420.8010@eiger.cip.physik.uni-muenchen.de> (raw)
In-Reply-To: <20050312.225725.125114910.eijiro_sumii@anet.ne.jp>


On Sat, 12 Mar 2005, Eijiro Sumii wrote:

> 2. Some programs get much slower for larger heaps, even though they
>    don't seem to trigger any GC.  An example is such programs is given
>    below.  Why is this?  (There also exist programs that are not
>    affected at all, so this is not because of the initialization
>    overhead of the runtime system.)

Quite in general, Cache hierarchy may be an issue here. The CPU can only 
hold a small amount of data in its L1 cache, which is quite fast. Next, 
there are L2 and then L3 caches (should you have that), but if you have to 
do a lot of real memory access, that usually will kill you. Especially if 
your address space is so badly scrambled that the CPU constantly needs to 
re-load its address translation cache (called translation lookaside buffer 
for x86). Worst case situation on a 3-level MMU system is that you will
have to do four memory reads for one word of data.

So, as a quite general rule when doing computationally challenging 
algebraic stuff in a functional language: try hard to design your data 
representation in such a way that you minimize RAM access. If you can 
e.g. encode short lists of small integers into a fixnum-integer, then do 
so. A few shift and masking operations do not matter much for many 
pipelined processors, provided the code can be held in the cache. Memory 
access does. One can overdo it, though: if you need ten times more code to 
get rid of a simple memory access, you're on the wrong track. Code also 
has to be transported to the CPU core.

-- 
regards,               tf@cip.physik.uni-muenchen.de              (o_
 Thomas Fischbacher -  http://www.cip.physik.uni-muenchen.de/~tf  //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y)           V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))                  (Debian GNU)


  reply	other threads:[~2005-03-13 12:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-13  3:57 Eijiro Sumii
2005-03-13 12:52 ` Thomas Fischbacher [this message]
2005-03-13 14:52   ` [Caml-list] " Eijiro Sumii
2005-03-13 16:17     ` Kurt Welgehausen
2005-03-13 17:41       ` Eijiro Sumii
2005-03-13 23:12 ` Damien Doligez
2005-03-14 15:17   ` Ken Rose
2005-03-15 19:39     ` 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=Pine.LNX.4.61.0503131341420.8010@eiger.cip.physik.uni-muenchen.de \
    --to=thomas.fischbacher@physik.uni-muenchen.de \
    --cc=caml-list@inria.fr \
    --cc=eijiro_sumii@anet.ne.jp \
    --cc=sumii@saul.cis.upenn.edu \
    /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).