Hi Dominik, I tried to use your package and you are missing a dependency for the `scribble-math` package in your info.rkt file, this has to be installed separately otherwise your package won't install.
However, I tried to use the `vector-futures-sort!` function and got an error: > (vector-futures-sort! #(3 1 7 6 4) <) . . vector-futures-sort!: broke its own contract promised: vector? produced: #<void> in: the res result of (->i ((unsorted vector?)) ((compare procedure?)) (res vector?)) contract from: <pkgs>/futures-sort/main.rkt blaming: <pkgs>/futures-sort/main.rkt (assuming the contract is correct) at: <pkgs>/futures-sort/main.rkt:40.2 > I would also be interested to know what performance gains did you get by using futures. I experimented with futures a few years ago and noticed that they will block when accessing shared data structures. My understanding is that all the futures will wait for each other while trying to access and set elements in the vector and this the execution will be mostly serial with no performance gains. I am curious if anything has changed with regards to this in the last few years. Alex. On Monday, October 7, 2019 at 9:01:25 PM UTC+8, Dominik Pantůček wrote: > > Hello, > > over the course of past few months I have been tasked with solving a > (real-world) problem of sorting the sums of all possible combinations of > numbers. Some boring accounting stuff revolving around invoices. As the > total number of combinations is 2^N where N is the number of source > numbers, this task got "interesting" once there were more than 24 > numbers - that is on my laptop with: > > model name : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz > > 4 cores, 8 hyper-threads and 16GB RAM. > > Long story short, I had to implement a custom merge-sort for fxvectors > and managed to leverage futures for fully parallel execution. Now in > some spare time, I slightly polished the code and released it as > "futures-sort" package. > > The source code is available on GitHub[1] and it is already in Racket > package index[2]. > > The package provides four sorting functions - two for vector? and two > for fxvector?. There are two variants of each, one with progress > reporting and one without. For the original task I needed to show > progress using racket/gui gauge% and it might be helpful for others > (it's just a callback that gets current and total number of merges > performed regularly). > > I would really appreciate any feedback regarding the naming conventions, > code style and generally anything else. > > Yes, the tests are not there (yet). > > The same algorithm without futures runs on par with Racket's default > sorting routines (tested for sets upto 2^30 - only 16G of memory here) > and for fixnums it is even (very slightly but consistently) faster than > vector-sort alone. With parallelism using futures it runs roughly N > times faster where N is the number reported by (processor-count). > > I have already some benchmark results available and once I get more data > I am more than happy to share it as well. > > The parallelism is configurable as parameter. > > And yes, all of this can be seen in the documentation which is included > but I still have to look into how to build it - I was sort of assuming > this works automatically based on what I see for example in > scribble-math[3][4]. Any help with getting this right is also more than > welcome. > > > Lastly - thanks go out to Jens Axel Søgaard for pointing out that > fixnums and fxvectors might help (and why) and also to other helpful > folks on #racket at Freenode. > > > Cheers, > Dominik > > > [1] https://github.com/dzoep/futures-sort > [2] https://pkgd.racket-lang.org/pkgn/package/futures-sort > [3] https://docs.racket-lang.org/scribble-math/index.html > [4] https://pkgd.racket-lang.org/pkgn/package/scribble-math > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/cc4e09cd-e968-4edf-8046-90e3cadb38fb%40googlegroups.com.