> This nice funktional interface runs with no measurable speed overhead
> compared to old cases. Also this is essentially python generators and
> this code runs in 0.3s where a python generator example runs in 0.5s,
> using delimited continuation we are talking about 6-7s.
That's quite amazing!
I have been working on improving the interface, And this works
(define gen
(make-generator
(lambda (x)
(let lp ((i 0))
(when (< i 2000)
(return x i)
(lp (+ i 1)))
(define (test)
(let ((g (gen)))
(let lp ((s 0))
(let ((i (next g)))
(if
(define (f x)
(let lp ((i 0))
(if (< i 10)
(begin
(pk 'value-from-parent (pause x i))
(lp (+ i 1))
(define (test-1)
(let ((x (make-pause-stack))
(ret 0))
(let lp ((i 0))
(let-values (((k x) (resume x (- i
(cond
((= k
Hi,
I'm trying to understand this.
The example of a generator which you give below counts upwards, but I don't
see how the value of n is passed out of the generator.
Could you give another example of a generator which does pass out the
values, along with a usage case which prints out the values
-- Forwarded message -
From: Stefan Israelsson Tampe
Date: Sat, Feb 12, 2022 at 5:04 AM
Subject: Re: Pausable continuations
To: Vijay Marupudi
I would say that they represent the same idea but that using separate
stacks is an optimization and I intended to explore what to
gain
The case with A simple loop of 20M operations are now down to 0.3 s that's
almost 20X improvements over
the best delimited continuation example (6s). Cpython takes 0.5s!
On Fri, Feb 11, 2022 at 1:10 PM Stefan Israelsson Tampe <
stefan.ita...@gmail.com> wrote:
> Hmm, I can improve the delimited co
This is exciting work, thanks for sharing! Maybe non-continuable
exceptions could be based on pausing continuations.
~ Vijay
Hmm, I can improve the delimited continuation speed slightly by doing the
below code
(define prompt (list 1))
(define (f2)
(let lp ((i 0))
(when (< i 2000)
(begin
(abort-to-prompt prompt)
(lp (+ i 1)
#f)
; 5.906402s real time, 12.297234s run time. 8.894807
I managed to make jitted code work for an example, speeds up the code up
2x. So in 1s ther is 40M ops per s
overhead in the generator construct, that's essentially 4x slower the
fastest it can do in a very simple loop. And matches
pythons generators and are 15x faster than the example code I have a
I did some benchmark, consider this code below. Let's turn off the jit. Then
a 20M loop using normal delimited continuations yields,
;; 7.866898s real time, 14.809225s run time. 9.652291s spent in GC
With a pausing continuation or generator we end up with,
;; 0.965947s real time, 0.965588s run t
Consider a memory barrier idiom constructed from
0, (mk-stack)
1. (enter x)
2. (pause x)
3. (leave x)
The idea is that we create a separate stack object and when entering it, we
will swap the current stack with the one in the argument saving the current
stack in x and be in the 'child' state and
11 matches
Mail list logo