Hi all,
For the longest part I’ve been doing normal Rust, and have gone through Jon’s latest video on the 1brc challenge and his brrr example.
This was great as a couple aspects “clicked” for me - the process of taking a raw pointer to bytes and converting them to primitive types by from_raw_parts or u64::from_ne_bytes etc.
His example resolves around the need to load data into memory (paged by the kernel of course). Hence it’s a read operation and he uses MADV to tells the system as such.
However I am struggling a wee bit with layout, even though I conceptually understand byte alignment (https://garden.christophertee.dev/blogs/Memory-Alignment-and-Layout/Part-1) in terms of coming up with a sma…
Hi all,
For the longest part I’ve been doing normal Rust, and have gone through Jon’s latest video on the 1brc challenge and his brrr example.
This was great as a couple aspects “clicked” for me - the process of taking a raw pointer to bytes and converting them to primitive types by from_raw_parts or u64::from_ne_bytes etc.
His example resolves around the need to load data into memory (paged by the kernel of course). Hence it’s a read operation and he uses MADV to tells the system as such.
However I am struggling a wee bit with layout, even though I conceptually understand byte alignment (https://garden.christophertee.dev/blogs/Memory-Alignment-and-Layout/Part-1) in terms of coming up with a small exercises to demonstrate better understanding.
Let’s come up with a trivial example. Here’s what I’m proposing
file input, similar to the brrr challenge
read into a memory map, using Jon’s version. Later we can switch to using the mmap crate
allow editing bytes within the map
assume it’s a mass of utf8 text, with \n as a line ending terminator. No delimiters etc.
If you have any further ideas, examples I can work through to get a better grasp - they would be most welcome.
I’ve also come across the heh crate https://crates.io/crates/heh which has an AsyncBuffer https://github.com/ndd7xv/heh/blob/main/src/buffer.rs and I’m visualising something along these lines.
May be a crude text editor where its view is just a section (start/end) looking into the map - the same way we use slices. Just an idea…
Thanks!
P.S I have also worked through the too many linked lists examples.