I’m nowhere near on your level but this was a great post and I loved your Dante quote
Maybe potential game jam entries could use Vulkan with this. https://itch.io/jam/racket-2019-gamejam
Does anyone know where I can find DrScheme binaries which will still run under Windows 95/NT4/2000? Just nostalgia purposes. I tried http://archive.org\|archive.org, couldn’t get a valid download link (where the file was saved by them). Thanks.
Yes, I was just noticing that.
I’ve updated the DNS entry. We’ll see if that turns out to be enough.
If I have an FFI C library that blocks on a socket (accepting/responding to msgs) can I still use a Racket thread to kick that off on its own or is this a special case where I need to use something like places?
From the Wikipedia page on SICP. Alyssa P. Hacker, a Lisp hacker
Ben Bitdiddle, a hardware expert
Cy D. Fect, a "reformed C programmer"
Eva Lu Ator, an evaluator
Lem E. Tweakit, an irate user
Louis Reasoner, a loose reasoner
Can anyone explain the Alyssa pun?
“a lispy hacker” :wink:
Thanks!
I started to copy the files to http://www.cs.utah.edu\|www.cs.utah.edu, and now I remember that http://www.cs.utah.edu\|www.cs.utah.edu was once a mirror for http://download.plt-scheme.org\|download.plt-scheme.org and already has everything:
https://www.cs.utah.edu/plt/download.plt-scheme.org/bundles/
@artemchernyak has joined the channel
Excellent, thanks!
@spdegabrielle That would be amazing. I’d have to confirm that swap chain/presentation works first. Hopefully I can before the festivities begin
IIRC if the C library only does blocking io then you will have to put it in a place or it will block the Racket VM.
If it has some sort of polling construct you can possibly make an event for it and put the poll and call in a Racket thread.
If you can get the underlying filehandle you can sometimes use that for polling as well.
ffi/unsafe
does not provide a _char
… Is that to help make sure people use _bytes/nul-terminated
?
I’m just now seeing that I cannot pass a byte string through (_cpointer _int8)
.
Would be even closer with “Alice”
Should we put the older versions on http://download.racket-lang.org\|download.racket-lang.org?
I think we should just bring http://download.plt-scheme.org\|download.plt-scheme.org back, and I’ve nudged that along.
So I can convert the C socket in / out streams (once they’ve been opened on the C side), into something Racket can communicate with, put that on a separate Racket thread and then if the in stream blocks, I won’t freeze up the Racket VM? Right now, I have a partially completed Racket version of the C library where the in stream can block in a Racket thread and the RVM won’t hang.
I thought I read that there’s only 1 OS thread for running all of Racket. If that’s the case, I don’t know how I’m able to block on the in stream in a Racket thread unless the low level stuff checks for a “would block” before ever attempting a read. Gives the illusion that blocking is going on when it’s really polling underneath that I don’t programmatically see at my software layer?
You would need to poll the stream for data and then perform the blocking operation. Something like
(sync (handle-evt (unsafe-fd->evt fd 'read #t) (lambda (_ignore) (do-blocking-read))))
Racket IO is async, so reading a port in one thread doesn’t block others. But if you go into the C world and never get back to the Racket world it will block.
Thanks for your help!
I really thought that the ffi had a way to call in a new OS thread, but I can’t find it
That would be nice.
If you have a file descriptor and you’re really just calling read
on it, the simplest thing to do is turn it into a Racket port using unsafe-{file-descriptor,socket}->port
, and then Racket will handle reading in a non-blocking, thread-friendly way.
For other blocking calls, like accept
, you can use unsafe-poller
. (The sync
expression that SamPhillips would mostly work, but there’s a race between checking for a ready fd and performing the read.) The implementation of unix-socket-accept-evt
is an example of using unsafe-poller
.
Out of curiosity where is the race?
While Racket is waiting for blocking system operations (e.g. system*
), can Racket perform aggressive GC or do something else useful?
Calling system*
blocks only the calling thread, not any other Racket thread (or place).
The runtime system won’t GC during system*
just because it has nothing else to do, but it will perform a GC as usual if other work triggers it.
Because I’ve been thinking about how to get http2 support in Racket, here’s a fun http2 fact: on average, the first 40 or so GET requests you send to a server fit in a single TCP packet (around 20 bytes per request). The first 400 or so fit in the ten packets you can send before TCP congestion control requires the client to wait for an ACK before sending more messages (CWND). So when talking to the same server, with http2, there is almost no network overhead to sending individual GET requests instead of one single batch GET request.
info from this great blog post: https://www.mnot.net/blog/2019/10/13/h2_api_multiplexing