174 karma · joined Apr 1, 2019 (7y ago) · 49 submissions
1.
Does "vpmovzxbd" scare you? Here's why it doesn't have to(questdb.io ↗)
1 points · by haxen · 2y ago · discuss
comment 2y ago · link · parent
It's quite a bit more than that, just the code discussed in the post is around 20 instructions, and there's a bunch more concerns like finding the delimiter between the name and the temperature, and hashtable operations. All put together, it comes to around 80 cycles per row.
When explaining the timing of 1.5 seconds, one must take into account that it's parallelized across 8 CPU cores.
comment 2y ago · link · parent
comment 2y ago · link · parent
SSE was successfully applied to finding the delimiter between the name and the temperature, though.
comment 2y ago · link · parent
The general class of techniques used is called SWAR -- SIMD Within A Register, because it uses the regular ALU instruction set to achieve the effect of SIMD (Single Instruction, Multiple Data).
The code in question was submitted by Quan Anh Mai (@merykitty on GitHub).
comment 2y ago · link · parent
comment 2y ago · link · parent
But you're right about the contest -- each program was measured five times in a row, and there was enough RAM to fit the entire file into the page cache.
The best time using all 32 cores (64 hyperthreads) on the evaluation machine was 323 milliseconds.
comment 2y ago · link · parent
To be fair, I didn't try out the hashbrown API. Maybe that, together with FxHash, would have been enough for the official dataset with 97% of keys < 16 bytes. But, I was optimizing for the "10k" dataset as well, with a lot of longer keys, and hashing just the first 8 bytes was the winning idea.
comment 2y ago · link · parent
HashMap was quite a bottleneck in Rust as well, for many reasons, not just the key allocation problem. But it was very easy to implement the same kind of custom hashtable, which almost by default ends up having a better memory layout than in Java.
https://github.com/mtopolnik/rust-1brc/blob/main/src/main.rs
I bet I could improve on it just a bit and match the Java time. Not sure about topping it, though.
comment 2y ago · link · parent
I took part in the One Billion Row challenge (1BRC). It was a lot of fun, but also a great learning experience. People came up with some pretty incredible optimization tricks. When you put them all together, it's a huge number, and they are all mingled up in individual solutions. They also happen on many levels -- from quite high, to incredibly low and detailed.
In retrospect, I could see there was a good number of tricks that are relatively easy to grasp, and reusable in other projects. I felt the urge to do a writeup that captures this knowledge in one place, isolating and explaining each of the tricks.
18.
Billion Events per Second at Millisecond Latency: NEXMark at Giga-Scale(jet-start.sh ↗)
21 points · by haxen · 5y ago · discuss
comment 6y ago · link · parent
comment 6y ago · link · parent
https://jet-start.sh/blog/2020/06/09/jdk-gc-benchmarks-part1
The point is that Jet can track several million distinct keys, even on a single machine, and finding velocity vectors boils down to linear regression sliding window against two FP variables.
If your concern is why you would specifically want to track locations, the answer is that there are plenty location-based apps that track locations with user's consent.
comment 6y ago · link · parent
Beam is just an API layer with different backing implementations. But you don't typically use Beam to work with Jet, instead you use its own Pipeline API which is mostly like Java Streams. Jet will also soon get an SQL API.
comment 6y ago · link · parent
For the distinction you have in mind, I see the terms "colored" vs. "non-colored functions" to be used the most, and they are both within the "cooperative multithreading" space.
comment 6y ago · link · parent
Virtual threads are of the former kind. (At least as long as we don't involve the forced preemption feature).
comment 6y ago · link · parent
This is exactly the same as within the "colored" subspace in a language that has this distinction. As long as all the functions you call are suspendable, you equally have no idea which one will actually suspend.
So, without forced preemption based on GC safepoints, and as long as there is any blocking operation left in the library, Loom qualifies as a cooperative multithreading system.
comment 6y ago · link · parent
You're going to allocate a single memory block that contains all the state of that object, which of course includes the superclass state. But that has nothing to do with the depth of the class hiererarchy.
> you're gonna be allocating functions everywhere as well.
If by "function" you mean a "Java method", they are code and not data, and they are not allocated dynamically at all.
In any case, this would have nothing to do with them being private or final. These options decide whether there will be an invokevirtual or invokespecial instruction to call them, where invokevirtual has more cost only before getting JIT-optimized.