f8l has quit [Ping timeout: 240 seconds]
alexshendi has quit [Ping timeout: 268 seconds]
f8l has joined #picolisp
aw- has joined #picolisp
aw- has quit [Ping timeout: 240 seconds]
aw- has joined #picolisp
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp
<
cess11>
tankfeeder: by comment mike line do you mean both parentheses at the end or just one?
<
tankfeeder>
just line
<
tankfeeder>
parenthesis specially on different lines
anjaa has quit [Ping timeout: 246 seconds]
<
cess11>
I don't think it is @ that does it, rather that 'and stops when there's just NIL in the 'while body.
<
cess11>
Not sure though.
anjaa has joined #picolisp
<
Regenaxer>
tankfeeder, the above link does not work?
<
Regenaxer>
I get just "That link has no power here" ...
<
Regenaxer>
strange message, no idea what it means
<
Regenaxer>
Hmm, (dec @) subtracts 1 from the return value of (gt0 @)
<
Regenaxer>
What is the problem?
<
Regenaxer>
"so turn out @ will be set only inside loop body"?
<
Regenaxer>
'while' sets it
<
Regenaxer>
all conditional functions do set it
<
Regenaxer>
in this example it is 'and' and 'while' who set it
<
Regenaxer>
If you do
<
Regenaxer>
(while (and (gt0 @) (dec @))
<
Regenaxer>
#{(println 'Mike)}# )
<
Regenaxer>
(println 'boom) )
<
Regenaxer>
then 'while' returns NIL, right?
<
Regenaxer>
so 'boom' is not printed because of the 'and'
<
Regenaxer>
as cess11 said
<
Regenaxer>
*if* the body of 'while' is ever executed, it returns 'Mike'
<
tankfeeder>
ok, then i need something else
<
Regenaxer>
What is your plan?
<
tankfeeder>
this is working thread ring
<
tankfeeder>
want it be perfect.
<
Regenaxer>
What is not perfect?
<
Regenaxer>
hmm, I see
<
Regenaxer>
the (prog 1) just to set '@'
<
tankfeeder>
hour debugging
<
Regenaxer>
What is the loop required to do? Just yield the next decremented number?
<
tankfeeder>
503 co
<
tankfeeder>
in ringt
<
tankfeeder>
in ring
<
tankfeeder>
start from first or any
<
tankfeeder>
start from 5000000 as number
<
tankfeeder>
send dec to next
<
Regenaxer>
Why do you not use a normal loop? eg 'for'?
<
Regenaxer>
(for ... (yield ..)) ?
<
Regenaxer>
Should be easy with coroutines, that's what they are fore
<
Regenaxer>
Why is this '@' handling necessary?
<
tankfeeder>
because i receive number from prev co
<
Regenaxer>
(I don't remember the details of the task, and don't want to dig into it now ;)
<
Regenaxer>
Sounds easy
<
Regenaxer>
but probably not ;)
<
Regenaxer>
Each co sends gets a number, decrements it, and sends it to the next one?
<
tankfeeder>
ive implement it my way
<
Regenaxer>
yes, good
<
Regenaxer>
Can't it be something simple like (not tested):
<
Regenaxer>
(de ring (M N)
<
Regenaxer>
(co (intern (pack 'ring M))
<
Regenaxer>
(let N (intern (pack 'ring N))
<
Regenaxer>
(while (yield)
<
Regenaxer>
(yield (dec @) N) ) ) ) )
<
Regenaxer>
This does not work, but principially?
<
Regenaxer>
Hmm, I see, two 'yields' are not an option
<
Regenaxer>
but (M ...)?
<
Regenaxer>
if you define a separate function for each one
<
tankfeeder>
cant test right now
<
cess11>
Maybe 'task is easier, not sure.
<
Regenaxer>
I'll take a look
<
tankfeeder>
if you send to neib it must be already running and waiting for number
<
tankfeeder>
cess11: task ring already implemented
<
tankfeeder>
Regenaxer: so i loop via while inside every child and get number and send to next if gt0
<
tankfeeder>
my implementation is working in general
<
tankfeeder>
i added printl and i how number moves from co to co
<
tankfeeder>
and see
<
tankfeeder>
and see how number moves from co to co
<
Regenaxer>
Let me check my two old versions
<
Regenaxer>
with tasks and processes
<
Regenaxer>
I think should be analog with coroutines
<
Regenaxer>
You try to do all with 'yield', but normally you call and continue a coroutine with 'co'
<
tankfeeder>
i dont understand
<
Regenaxer>
I investigate my old solutions
<
Regenaxer>
alioth/taskring.l
aw- has quit [Ping timeout: 248 seconds]
<
Regenaxer>
I don't understand the termination condition any more
<
Regenaxer>
I think it must be something like that, but it does not give the right return value:
<
Regenaxer>
(for N 503 # Start all 503 coroutines
<
Regenaxer>
(co (intern (pack 'ring N))
<
Regenaxer>
(let (N N Send (intern (pack 'ring (if (= 503 N) 1 (inc N)))))
<
Regenaxer>
(for (I (yield) (gt0 (yield (dec I) Send)))
<
Regenaxer>
(setq I @) )
<
Regenaxer>
N ) ) )
<
Regenaxer>
(co 'ring1 50000)
<
Regenaxer>
The first 'yield' is to start
*first* all 503 coroutines
<
Regenaxer>
So the call (co 'ring1 50000) is nonsense
<
Regenaxer>
the 50000 is ignored. hmm ...
<
Regenaxer>
I must get my head around coroutines agais
<
Regenaxer>
using them too seldom ;)
aw- has joined #picolisp
<
tankfeeder>
whats wrong with my variant?
<
Regenaxer>
you said it is not perfect
<
Regenaxer>
and indeed it looks too complicated for my feeling too
<
Regenaxer>
seems to work
<
Regenaxer>
(for N 503 # Start all 503 coroutines
<
Regenaxer>
(co (intern (pack 'ring N))
<
Regenaxer>
(let (N N Send (intern (pack 'ring (if (= 503 N) 1 (inc N)))))
<
Regenaxer>
(for (I (yield) (gt0 (yield (dec I) Send)) @))
<
Regenaxer>
N ) ) )
<
Regenaxer>
(println (yield 50000 'ring1))
<
Regenaxer>
gives 204
<
tankfeeder>
i will test and announce
<
Regenaxer>
Instead of (for (I (yield) (gt0 (yield (dec I) Send)) @)) you could also write
<
Regenaxer>
(for (I (yield) (gt0 (yield (dec I) Send)))
<
Regenaxer>
(setq I @) )
<
tankfeeder>
try now bench on 5000000
<
Regenaxer>
or (let I (yield) (while ...
<
tankfeeder>
how many secs?
<
Regenaxer>
'for' is shorter
<
Regenaxer>
on my tablet user 0m0.393s
<
Regenaxer>
On a multi-core machine the parallel processes might be faster (?)
<
tankfeeder>
much faster
<
Regenaxer>
did you measure?
<
tankfeeder>
i cant test right now
<
tankfeeder>
but 5m on 0.3 is very fast
<
tankfeeder>
golang 1.9secs
<
tankfeeder>
i will take your code
<
Regenaxer>
afp bbl
<
m_mans>
benchmarking? :)
docmathoc has joined #picolisp
<
tankfeeder>
official benchmarking
<
tankfeeder>
crystal 0.3sec
<
tankfeeder>
golang1.9 1.1sec
<
tankfeeder>
tankfeeder: ~17secs
<
tankfeeder>
Regenaxer: ~20secs
<
tankfeeder>
thread ring on 503 threads for 5000000 number
<
aw->
tankfeeder: can you compare language build times as well?
<
aw->
what are we benchmarking here?
<
tankfeeder>
oh come on, its ok
<
tankfeeder>
i dont care.
docmathoc has quit [Remote host closed the connection]
docmathoc has joined #picolisp
<
Regenaxer>
tankfeeder: How about threadring.l on multi-core?
<
tankfeeder>
the same
<
tankfeeder>
cant find difference
<
tankfeeder>
secs on the same vmware
<
tankfeeder>
2cpu-2cores
<
tankfeeder>
next week try real hardware, want to reinstall server
<
Regenaxer>
I try on my server with 6 cores
<
tankfeeder>
then i do it today
<
tankfeeder>
i have modern with 16 cores
<
Regenaxer>
Start value 50000000?
<
tankfeeder>
you wrote 5B
<
tankfeeder>
you wrote 50M
<
Regenaxer>
yes, took from those old versions
<
Regenaxer>
(comment on top)
<
Regenaxer>
ok, then 5M
<
Regenaxer>
Hmm, takes very long
<
Regenaxer>
better take a smaller one?
<
tankfeeder>
16cores - 16secs
<
Regenaxer>
I try 50000
<
tankfeeder>
5M is standart
<
tankfeeder>
it is all ok
<
tankfeeder>
goal was to implement
<
tankfeeder>
its fast.
<
tankfeeder>
search for Threadring
<
Regenaxer>
coroutines are by far the fastest. Is that correct?
<
Regenaxer>
$ time ../pil taskring.l 50000
<
Regenaxer>
real 0m7,517s
<
Regenaxer>
$ time ../pil threadring.l 50000
<
Regenaxer>
real 0m3,418s
<
Regenaxer>
$ time ../pil coroutinering.l 50000
<
Regenaxer>
real 0m0,237s
docmathoc has quit [Ping timeout: 256 seconds]
docmathoc has joined #picolisp
docmathoc has quit [Ping timeout: 240 seconds]
aw- has quit [Quit: Leaving.]
docmathoc has joined #picolisp
orivej has joined #picolisp
libertas has quit [Quit: Lost terminal]
orivej has quit [Ping timeout: 256 seconds]
docmathoc has quit [Quit: ttfn chaps]
zod_ has joined #picolisp
zod_ has quit [Client Quit]
orivej has joined #picolisp