[racket-users] [ANNOUNCE] Xiden is now in beta

2021-03-19 Thread Sage Gerard
Hi folks, About a year, 1384 commits, 489 tests, ~10k LOC, and 2" on my waistline later, Xiden is in beta. An update is pending on the default catalog. https://github.com/zyrolasting/xiden Xiden is a dependency manager I wrote to support use cases that I could not get working with `raco pkg`.

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread David Storrs
Ah. Thanks. On Fri, Mar 19, 2021 at 1:33 PM Jay McCarthy wrote: > It is not a built-in thing. I am talking about the use-pattern of a > condition variable: > https://en.wikipedia.org/wiki/Monitor_(synchronization)#Condition_variables > > -- > Jay McCarthy > Associate Professor @ CS @ UMass

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread Jay McCarthy
It is not a built-in thing. I am talking about the use-pattern of a condition variable: https://en.wikipedia.org/wiki/Monitor_(synchronization)#Condition_variables -- Jay McCarthy Associate Professor @ CS @ UMass Lowell http://jeapostrophe.github.io Vincit qui se vincit. On Fri, Mar 19, 2021 at

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread David Storrs
On Fri, Mar 19, 2021 at 12:02 PM Jay McCarthy wrote: > The best thing is to use a semaphore instead of a mutable reference. > If you can't do that, then I think that you should combine the mutable > reference with a signaling semaphore. If you can't do that, then I > can't think of anything but

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Sam Tobin-Hochstadt
I went from numbers around 1000 ms to 950 ms to 900 ms. There was variance around those numbers, but it was pretty consistent. For more precise answers, there are a few things you can try. One is to measure instructions instead of time (ie, with perf). Another is to run it a bunch of times and

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread David Storrs
Cool. Thank you both. On Fri, Mar 19, 2021 at 12:15 PM Sam Tobin-Hochstadt wrote: > Another possibility is to send a message on a channel when the user is > set, and then just wait with `sync` for a message to appear on the > channel. > > Sam > > On Fri, Mar 19, 2021 at 12:02 PM Jay McCarthy

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Laurent
Sam: How do you accurately measure such small speed-ups? On my machines, if I run the same program twice, I can sometimes see more than 10% time difference. On Fri, Mar 19, 2021 at 4:10 PM Sam Tobin-Hochstadt wrote: > Use `#:authentic`, and `unsafe-vector*-{ref,set!}` saved about 50 more > ms

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread Sam Tobin-Hochstadt
Another possibility is to send a message on a channel when the user is set, and then just wait with `sync` for a message to appear on the channel. Sam On Fri, Mar 19, 2021 at 12:02 PM Jay McCarthy wrote: > > The best thing is to use a semaphore instead of a mutable reference. > If you can't do

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Sam Tobin-Hochstadt
Use `#:authentic`, and `unsafe-vector*-{ref,set!}` saved about 50 more ms on my machine. Then getting rid of `set!` and just re-binding the relevant variables produced another 50 ms speedup. https://gist.github.com/7fc52e7bdc327fb59c8858a42258c26a Sam On Fri, Mar 19, 2021 at 7:21 AM Sam

Re: [racket-users] Best way to say 'block until true'?

2021-03-19 Thread Jay McCarthy
The best thing is to use a semaphore instead of a mutable reference. If you can't do that, then I think that you should combine the mutable reference with a signaling semaphore. If you can't do that, then I can't think of anything but a poll. -- Jay McCarthy Associate Professor @ CS @ UMass

[racket-users] Best way to say 'block until true'?

2021-03-19 Thread David Storrs
Suppose I have a function that tests for some condition, e.g. (define current-user (make-parameter #f)) (define (current-user-set?) (not (false? (current-user))) What is the best way to say "wait until 'current-user-set?' returns true"? I've been through the Events chapter in the Reference and

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Laurent
(Welcome to Racket v8.0.0.1 [cs]. ) All results are measured on my laptop on the 10x file with `$ time racket `, thus including the Racket VM. * Bogdan's version with #lang racket/base: 1s. * Dominik's version with vectors of length 256 (instead of 26) and splitting on spaces/return/newline only

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Bogdan Popa
Nice! It's worth pointing out, though, that by limiting yourself to alpha chars, you're processing about 8% less data and the results don't pass the tests. :P $ wc kjvbible_x10.txt 998170 8211330 43325060 $ sed 's/[a-zA-Z ]//g' < kjvbible_x10.txt | wc 998170 739310 3600800

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Dominik Pantůček
Another attack of [1]. But yeah, why not do some [2]. Trees to the rescue [3]. $ racket --version Welcome to Racket v8.0 [cs]. $ racket countwords-bogdan2.rkt https://xkcd.com/386/ [2] http://phdcomics.com/comics/archive.php?comicid=1735 [3]

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Sam Tobin-Hochstadt
One minor additional suggestion: if you use #:authentic for the struct, it will generate slightly better code for the accessors. Sam On Fri, Mar 19, 2021, 6:18 AM Bogdan Popa wrote: > I updated the gist with some cleanups and additional improvements that > get the runtime down to a little over

Re: [racket-users] Word Count program/benchmark performance

2021-03-19 Thread Bogdan Popa
I updated the gist with some cleanups and additional improvements that get the runtime down to a little over 1s (vs ~350ms for the optimized C and Rust code) on my maxed-out 2019 MBP and ~600ms on my M1 Mac Mini. Pawel Mosakowski writes: > Hi Bogdan, > > This is a brilliant solution and also