Zaid Humayun's Avatar

Zaid Humayun

@redixhumayun.bsky.social

Engineer @conviva | Figuring out databases

48 Followers  |  119 Following  |  73 Posts  |  Joined: 23.02.2024  |  2.0111

Latest posts by redixhumayun.bsky.social on Bluesky

Post image Post image

I keep getting lucky with the PR numbers

28.05.2025 18:20 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Nested match statements, as the Lord intended

10.05.2025 11:57 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

I like this thought process.

Easier to think of a database = storage layer + data model + query layer (language + optimizer)

06.05.2025 08:24 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Seems like itโ€™s all in preparation for an IPO

06.05.2025 08:01 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Its issues like this that make me thankful I finally jumped to having a dedicated Ubuntu box. Open source tools actually *just work*

05.05.2025 14:24 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

My toy database coming along quite nicely

28.04.2025 05:39 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Me trying to write code quickly in Rust

27.04.2025 19:04 โ€” ๐Ÿ‘ 3    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Really, really liking Rust's iterator pattern the more I use it!

Makes composition so much nicer to look at and reason about

06.04.2025 13:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

In the year of our lord 2025, this is not a heretical opinion solely because of the abysmal state of debugging tooling in Rust z

24.03.2025 03:37 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

The more Rust I write, the more I vibe with this meme

23.02.2025 15:27 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Kolkata got some banging food

21.02.2025 13:07 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

It has been 0 days since I've been bitten by Rust lifetimes

12.02.2025 10:36 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Iโ€™m fairly certain Amazon also does an LLM chatbot thing where itโ€™s pretending to be a person on chat.

The formulaic responses give it away.

04.02.2025 10:34 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Isnโ€™t this the exact same drama that happened with Ted Tsoโ€™o?

04.02.2025 07:52 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

The biggest drawback of any form of writing generated by LLM's is that it just doesn't feel very honest. The vibes are off

29.01.2025 08:05 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

Functional programming got jokes

28.01.2025 07:39 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Cache Conscious Hash Maps Hereโ€™s a link to the code on GitHub

If you found this interesting, give the full article a read which goes into much more depth and contains links to more interesting tidbits around Rust compiler optimizations

redixhumayun.github.io/performance/...

27.01.2025 14:43 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image Post image Post image

Now, we see much better performance when comparing cache stats for the 3 implementations.

It isn't enough to have contiguous memory access, you also need to be aware of the cache hardware and how many entries can fit per cache line.

27.01.2025 14:43 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

Doing all of the above requires you to know some information about your hardware, like the size of your cache and the size of a cache line.

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

We can do a more compact open addressing scheme which will fit 4 entries per cache line

Also, using u64 instead of Strings leads to better performance since Strings are always heap allocated

27.01.2025 14:43 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

The problem is the memory layout of the structs used for chaining and open addressing

With chaining, we only have pointers which are 8 bytes each so that's 8 per cache line in a 64 byte cache line

With open addressing, it's 24 bytes each so that's 2 per cache line with padding

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image Post image Post image

Profiling, however, shows very different results. It shows chaining and open addressing displaying roughly the same levels of cache performance.

Open addressing ends up performing better but that's only due to fewer overall instructions

27.01.2025 14:43 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image Post image

You can handle collisions via open addressing (linear probing). This is where you just search through every subsequent entry until you find one where you can insert the key-value pair.

This should be more cache friendly since the entire memory is contiguously allocated

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image Post image

You can handle collisions via chaining where each entry becomes a linked list. This is simple but tends to lead to fragmented memory since each node is allocated separately.

Fragmented memory should theoretically lead to poorer cache performance.

27.01.2025 14:43 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

Building a hash map is easy enough - a few public methods and a couple of internal methods to track when to resize the hash map

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Preview
Running Profiling Tools On Linux ยท Issue #9 ยท redixhumayun/learnings Run strace For Syscalls strace -e trace=mmap,munmap,brk -f ./target/debug/hashmap Remove brk from above if you're not interested in seeing smaller allocations. Depends on the use case you are profi...

My only real recommendation from the post is to not bother profiling on OSX! It's a locked down nightmare of an OS

I've covered all the steps required to get Linux up and running for profiling here: github.com/redixhumayun...

Apple requires jumping through too many hoops

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Cache Conscious Hash Maps Hereโ€™s a link to the code on GitHub

Here's a link to the full post

redixhumayun.github.io/performance/...

27.01.2025 14:43 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

I've been trying to understand profiling tools better and decided to build a cache conscious hash map as a way to get more familiar with the tooling.

I wrote a small blog post and I'll cover the high level points in this ๐Ÿงต

27.01.2025 14:43 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Post image

The database is the log

14.01.2025 17:45 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Although, this does beg the question of how to ensure Strings perform well with caches. Possibly they can't?

14.01.2025 15:18 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

@redixhumayun is following 19 prominent accounts