unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* fixnum? VM primitive, increasing fixnum operation speed
@ 2011-03-23  2:19 Andreas Rottmann
  2011-03-23  2:19 ` [PATCH] Add `fixnum?' VM primitive Andreas Rottmann
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Rottmann @ 2011-03-23  2:19 UTC (permalink / raw)
  To: guile-devel

This is another piece of my attempt at getting more speed out of the
`(rnrs arithmetic fixnums)' library.  The idea is that this patch would
be applied to master. I think, at least in the current form, it is not
eligible for 2.0.x, as it messes up the VM opcode numbers, which breaks
all .go files, IIUC.

After this patch has been applied, the R6RS fixnums library can be
adapted to use the new primitive.  I have locally already tried this,
and on top of the previous patch ("Take some lowhanging fruit to speed
up R6RS fixnum operations"), this one speeds up the ZIP benchmark by
another factor of 1.75, yielding a runtime of 15 seconds.  The fxxor
benchmark added by the previous patch gets a ~3x speed boost.

Now, I'm still not entirely satisfied, but these two patches should
cover the lowest hanging fruits without changing the semantics of the
fixnum operations.  

For well-behaved programs, it would not be necessary to do the checks
for fixnum-ness at all, neither for the arguments nor for the return
value.  This would in effect alias the fixnum operations to their
non-fixnum counterparts, violating R6RS, which demands exceptions to be
thrown if arguments or return values exceed fixnum range.  I conjecture
that this would give another noticable boost, as it would eliminate at
least a procedure call and the `fixnum?' checks.

I'd argue that deviating from R6RS in this area is not desirable; after
all I think the intention of the R6RS fixnum library is to provide
specialized operations so that implementations can provide fast-path
versions of the more general procedures when it is known that fixnum
range suffices -- the fact that fixnum arithmetic is actually *slower*
than general arithmetic on Guile is not a given, but an artefact of the
way they are currently implemented.

Ideally (at least speed-wise), all of the fixnum operations should be VM
primitives.  I'm not sure if we have enough opcode space for that.  It
also raises the question of maintainablity (which probably can be kept
in check with appropriate C preprocessor trickery), and how to deal with
the exceptions these procedures are required to throw.  As we probably
don't want to tie the R6RS exception system directly into VM, I was
thinking of using a fluid containing a procedure that does the actual
exception throwing; that fluid could be set by some R6RS library.

Well, this is getting quite long already, so I'll stop for now.  I'm
looking forward to any responses!

,,rotty



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-03-29 11:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23  2:19 fixnum? VM primitive, increasing fixnum operation speed Andreas Rottmann
2011-03-23  2:19 ` [PATCH] Add `fixnum?' VM primitive Andreas Rottmann
2011-03-24 22:01   ` Ludovic Courtès
2011-03-24 23:51     ` Andreas Rottmann
2011-03-25 10:40       ` Ludovic Courtès
2011-03-25 11:50         ` Andreas Rottmann
2011-03-25 13:21           ` Ludovic Courtès
2011-03-29 11:03             ` Andy Wingo
2011-03-28 18:48         ` Ken Raeburn
2011-03-29 10:55           ` Andy Wingo
2011-03-29 10:52       ` Andy Wingo
2011-03-29 10:48     ` Andy Wingo

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).