unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: [BDW-GC] Static allocation of subrs
Date: Sat, 31 Jan 2009 22:43:13 +0100	[thread overview]
Message-ID: <87vdrv179q.fsf@gnu.org> (raw)

Hello!

The `bdw-gc-static-alloc' branch now contains an implementation of
statically allocated subrs.  This was done in 2 steps:

  1. Using double-cells instead of single-cells for subrs [0].  The
     patch is quite nice in that it simplifies `procs.[ch]'.  This
     change is needed so that subrs don't contain a subr entry number
     allocated at run-time (the subr entry number is the index of the
     subr in the subr table).

     It does not introduce any storage overhead: previously, a subr
     consumed one cell and sizeof (scm_t_subr_entry), i.e., 2 + 4 = 6
     words; with the patch, a subr consumes one double cell and 2 words
     for `meta_info', i.e., 4 + 2 = 6.

     The change leaves the 24 MSBs of the first word of the cell unused.
     We might want to do something smart with all these bits.

     For these reasons, we may want to merge this patch in `master' as
     well.

  2. The second step does the actual work [1].  Currently, it only
     deals with subrs, i.e., primitive procedures with "relatively few"
     arguments (see `create_gsubr ()').

     To distinguish subrs (few arguments) from gsubrs (unrestricted
     arity, see `default:' in `create_gsubr ()'), a Dirty Hack(tm) was
     needed.  The hack is that `SCM_DEFINE' is an alias for a new macro
     `SCM_DEFINE_SUBR_reqX_optY_rstZ', where X, Y and Z are the number
     of required, optional and rest arguments.  If X, Y and Z are such
     that a raw subr can be used, then the macro is an alias for
     `SCM_DEFINE_SUBR', which does the actual static allocation;
     otherwise, it's an alias for `SCM_DEFINE_GSUBR', which is the same
     as `SCM_DEFINE' in `master'.

     The dirtiest part of the hack is the generation of "snarf-gsubr.h"
     which contains definitions of `SCM_DEFINE_SUBR_reqX_optY_rstZ' for
     a "reasonable" number of combinations of X, Y and Z (C++ template
     specialization would solve this problem much more elegantly...).

The good news is that it actually works.  :-)

I ran `gcbench.scm' with both BDW-GC branches and didn't observe any
significant difference.  The benefits are that (i) initialization should
be slightly faster, and (ii) running several instances of guile should
consume less memory since statically allocated data can be mapped
read-only by the loader and, consequently, the underlying physical
memory can be shared across instances.

Thanks,
Ludo'.

[0] http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=2ee5aa25dbd679b175707762f5961585027e1397
[1] http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=46f9baf49a8ea4461e8494c75a88b87d0f5c5195





             reply	other threads:[~2009-01-31 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-31 21:43 Ludovic Courtès [this message]
     [not found] ` <77A87EC6-5495-4F14-9AEB-3489B3AC0210@raeburn.org>
2009-02-02  8:42   ` [BDW-GC] Static allocation of subrs Ludovic Courtès
2009-02-02 21:48 ` Neil Jerram
2009-02-02 23:38   ` Ludovic Courtès
2009-02-03 20:13     ` Neil Jerram
2009-03-16 18:17       ` Ludovic Courtès
2009-02-11 23:19     ` Ludovic Courtès

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=87vdrv179q.fsf@gnu.org \
    --to=ludo@gnu.org \
    --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).