From: "Patrick R. Michaud" <[EMAIL PROTECTED]>
   Date: Mon, 31 Mar 2008 23:15:43 -0500

   On Mon, Mar 31, 2008 at 11:33:42PM -0400, Bob Rogers wrote:
   > Do you remember the discussion two years ago [1] about eliminating the
   > user stack in favor of arrays?  Chip made the following comment [2]:
   > 
   >    From: Chip Salzenberg <[EMAIL PROTECTED]>
   >    Subject: User stack: Worthwhile?
   >    Date: Mon, 27 Feb 2006 09:46:42 -0800
   > 
   >    Is there any other client of the user stack that can't be easily
   >    replaced by some kind of *Array?  It'd be nice to lop off such a
   >    low-value feature.
   > 
   > The response (including yours) was generally in favor of chucking this
   > vestige of 1960's computer architecture, but nobody took up the mantle.
   > What is the current thinking on this?

   Unless user stack operations are somehow more efficient than
   Resizable*Array PMCs, I don't see any reason for keeping them around.

   Pm

To my great surprise, save and restore are more than 5x slower compared
to array push/pop, at least according to the simple benchmarks attached.
The save/restore version takes about 19s (user CPU) on my machine, but
the array push/pop version takes less than 3.6s.  I haven't calibrated
the loops, nor have I tried types other than integer, but given the huge
difference for integers, I'm not sure I even need to bother.

   ================
   From: "jerry gay" <[EMAIL PROTECTED]>
   Date: Mon, 31 Mar 2008 20:43:12 -0700

   my current thinking agrees with chip's and patrick's. the closer to
   stackless we are, the better we handle threading. if you want to kill
   it, i will not stand in your way.

   ~jerry

The stack is actually stored in the Parrot_Context (oddly enough), so
IIUC it shouldn't affect threading.  True?

   ================
   From: chromatic <[EMAIL PROTECTED]>
   Date: Mon, 31 Mar 2008 20:45:14 -0700

   If it's clean, I'm all for it.

   -- c

I'm way too short of tuits right now, but I'll add a ticket when I get a
chance.  (Anybody who wants to help could start by rewriting code that
uses anything in src/ops/stack.ops -- and TIA!)

                                        -- Bob

.sub main :main
        .local pmc stack
        stack = new 'ResizableIntegerArray'
        .local int max_depth
        max_depth = 100
        ## Do this 100 000 times.
        I2 = 100000
again:
        ## Push max_depth integers, and pop them off again.
        I0 = max_depth
push_loop:
        save I0
        dec I0
        if I0 > 0 goto push_loop
pop_loop:
        restore I0
        if I0 < max_depth goto pop_loop
        dec I2
        if I2 > 0 goto again
        print "done.\n"
.end
.sub main :main
        .local pmc stack
        stack = new 'ResizableIntegerArray'
        .local int max_depth
        max_depth = 100
        ## Do this 100 000 times.
        I2 = 100000
again:
        ## Push max_depth integers, and pop them off again.
        I0 = max_depth
push_loop:
        push stack, I0
        dec I0
        if I0 > 0 goto push_loop
pop_loop:
        I0 = pop stack
        if I0 < max_depth goto pop_loop
        dec I2
        if I2 > 0 goto again
        print "done.\n"
.end

Reply via email to