[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: crashes with Fibers
From: |
Clément Lassieur |
Subject: |
Re: crashes with Fibers |
Date: |
Mon, 02 Jul 2018 11:22:32 +0200 |
User-agent: |
mu4e 1.0; emacs 26.1 |
Hi Amirouche,
Amirouche Boubekki <address@hidden> writes:
>> You test5 code should definitly work. Otherwise, it requires to pre-allocate
>> as many thread as you need before you know you will them. May be we can look
>> at it backward and say, that allocating a pool of threads in advance is more
>> interesting performance wise.
But the cost of allocating a thread pool is very small compared to the
cost of a doing git clone, which may take a minute or so.
>>> Anyway, try to spawn the thread and/or create the channel before you
>>> run fibers. I can't try that myself because of my slow connection which
>>> takes ages to install guile-fibers.
I can't do that because in the program I'm working on (Cuirass), the
first calls to RUN-FIBERS and SPAWN-FIBER happen very early[1]. They
are kind of the entry point of the program. At that time I don't know
how many repositories I will need to fetch simultaneously. Thus test3
and test6 don't meet my needs.
[1]:
https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git/tree/bin/cuirass.in#n144
>>> Something like:
>>
>> (use-modules (fibers))
>> (use-modules (fibers channels))
>>
>>> (define (test6)
>>> (let ((channel (make-channel)))
>>> (call-with-new-thread
>>> (lambda ()
>>> (put-message channel "hello world")))
>>> (run-fibers
>>> (lambda ()
>>> (spawn-fiber
>>> (lambda ()
>>> (format #t "~a~%" (get-message channel)))))
>>> #:drain? #t)))
>>
>> It works on my side.
>
> FWIW, the following code doesn't crash, but apparently does nothing:
>
> (define (test7)
> (let ((channel (make-channel)))
> (run-fibers
> (lambda ()
> (spawn-fiber
> (lambda ()
> (call-with-new-thread
> (lambda ()
> (put-message channel "hello world")))
> (format #t "~a~%" (get-message channel)))))
> #:drain? #t)))
This crashes the same way test5 does, you need to run it more :-)