You should do it in parallel, where your total number of partitions is the same as the number of channels supported by your CPU (4 or 8 most common I believe), but not greater than the number of CPUs available.
It is not clear what capacity is? Because according to Wikipedia the probability of the error depends on count of inserted elements. So Wikipedia uses ‘n ‘ in computation of error’s rate where n is count of inserted elements.
I loved the video, thank you very much for the explanations. Just to clarify my understanding, the copy problem when using a List<>. The problem would be because Parse is returning a List<> of structs and in the code below in foreach it would be copying the object to the loop's local variable? foreach (var line in lines) { sum += line.Amount; }
Great video. I would only recommend to work on a proper naming convention, as you named all of the tested methods with quite generic (nothing saying) names.
There's a potentially faster version of your no-multiplication bit hacks: // For n-bit integers, use a shift of (n-1) counter += value & (value & 1) << 31 >> 31; To explain it, I'll use 8-bit integers for brevity: 1. (value & 1): is the value odd? 2. << 31: move the pseudo-boolean value to the sign bit 3. >> 31: perform a sign-extending(!) shift to the right, essentially creating a move mask 4. value &: use the move mask to either zero out or keep the value It'll look something like this: Value: 5 1. (0b00000101 & 1) = 1 2. 1 << 7 = 0b10000000 3. 0b10000000 >> 7 = 0b11111111 4. 0b00000101 & 0b11111111 = 5 Value: 6 1. (0b00000110 & 1) = 0 2. 0 << 7 = 0 3. 0 >> 7 = 0 4. 6 & 0 = 0 This method eliminates not only the multiplication, but also the subtraction. Would be interested to see if it's actually faster, though
I was frankly suspicious of C# properties/accessors when I first learned of them, but they were so built into every example I came across that I figured there was something magical they were doing that I didn't understand. I've since just gone back to public fields as I find them easier to reason about. So much example C# code has a private backing field and a public property that just returns the private field (before the simplified get; set;).
The bug that you've mentioned at method B2 (8:06) seems not to be there anymore at .NET 7. However, the value of variable 'l' will be copied to eax register and it will be used later for the bound checking even though it's marked as unused at the front end code. And again thanks for the great video.
Could you also make some videos about the differences in output on different operating systems? It seems like on Linux / Mac even the MS version of dotnet (the dotnet/runtime) essentially uses the merged in Mono under the hood. As a result a lot of code output and performance characteristics work completely differently to what happens in the WIndows world.
in groupByLookup you dont deal with collisions,and when i see the imp of groupBy provided by Microsoft it look very similar to yours , so why the performance gap is hug ?!
You need your value to have a sufficient overlap in the bit mask, thus to avoid any uniformity problems and distribution locality the easiest way is to use k different hash functions. There are a couple of tricks to get this down to just two hashes and generate the rest but it was out of the scope of this video.
@@mfbx9da4 What you describe is essentially still k hash functions. It’s just that every one of those k hash functions has the same first step and its second step is to take a different digit from the same number (the one generated from the first step, or the one hash function that you talked about)
In fact, we rarely use Array in real world. Furthermore we can use multitasking for CPU-bound tasks or asynchronous for I/O-bound tasks to improve performance