Closed progval closed 1 year ago
I'll let @zommiommy have a look at this when he's back from DefCon as he wrote the code. One thing tho: test_par_comp
uses a toy example, so I think we need a bit more evidence that rayon does the right thing.
One reason for having a fixed number of threads is that in this way we can parallelize exactly. If we do 40 chunks but than rayon picks 39 threads this is going to be bad. To be tolerant to this kind of variance we should have significantly smaller chunks, which however means potentially more open files. But I think files are open sequentially at concatenation, so no big issue.
It is also true that in most cases after 8-10 threads you exhaust the cache/memory/disk bandwidth and then additional threads are useless.
Yeah, I'm starting a benchmark on the swh graph so we can verify this. Originally it was with chunks, but it was much slower
Also it turns out I won't use ParallelIterator as I expected; it's too hard to get an IndexedParallelIterator from reading a bunch of ORC files. So no big deal if you decide against this change
It takes 21h instead of 7h on the SWH graph, so this is probably a bad idea.
Motivations:
Clone
+Iterator
: the code previously assumed cloning an iterator would split it into chunks, but this is not guaranteed (items could be duplicates or interspersed).The changeset of this pull request may be hard to read because a large part of the code didn't change except for their indent level or variable names. I recommend reading commit-per-commit.
This alters the way work is distributed: rayon is now in charge of picking the number of threads and how to distribute chunks across threads. On my machine, the timings (i7-8700, 12 threads), this has no impact on the timings written by
test_par_comp
.Regarding the use of a macro, I wish I could do this purely within the type system, but `::chunks` and `IndexedParallelIterator::chunks` are surprisingly hard to unify.
I went as far as this, and it still didn't compile: ```rust pub trait MaybeParallelChunks { type Item; } impl<'a, I: 'a, Iter: Iterator