Was feeling curious today!
I wanted to test a simple but real-world task: hashing a 1GB file.
But with a twist, is pure Rust actually faster, or does calling C from Rust still win?
So I tried:
1. Rust (using the sha2 crate)
2. Rust + C (calling OpenSSL via FFI)
How it went?👇
Meta blocked PM Modi.
Meta helped those accounts on Instagram who were supporting CJP. They gained 300-400k followers in just 24hrs.
Meta DID NOT block any content on WhatsApp in the support of CJP protest.
Meta BLOCKED several content on Instagram that is against CJP.
None of these events happened by mistake.
@kdaigle COO of #github walked through the new github agent app experience exclusively at #githubconstellation. It was a crazy one!
Waiting it to be released!
7/7
Key Takeaways learnt:
- Rust is amazing but C still wins for low-level, hand-tuned primitives.
- FFI makes it easy to tap into C speed from Rust. Just wrap, link, and run the executable.
- Dynamic linking means smaller Rust binaries with easier updates.
Thank You
#Rust#C
Was feeling curious today!
I wanted to test a simple but real-world task: hashing a 1GB file.
But with a twist, is pure Rust actually faster, or does calling C from Rust still win?
So I tried:
1. Rust (using the sha2 crate)
2. Rust + C (calling OpenSSL via FFI)
How it went?👇
6/7
How did I call C from Rust?
Wrote a tiny C wrapper using SHA256_Init/Update/Final, compiled it into a .so (dynamic lib).
In Rust:
```
extern "C" {
fn sha256_c(input: *const u8, len: usize, out: *mut u8);
}
```
FFI makes it surprisingly smooth with ABI handled inside!
Leads to:
- Full cache miss
- Unnecessary vector search + LLM calls
So switched to semantic caching:
- Embed incoming queries (e.g., sentence-transformers)
- Compare via cosine similarity
- Short-circuit when similar intent is found
Result:
- Faster response & high cache hits!
While building a RAG pipeline with LangChain + ChromaDB, I ran into a caching problem:
Standard string-based caching was useless.
Same user intent, different phrasing
“What's the outlook for Tata Motors?” ≠ “How is Tata Motors performing?”
1/2
Dynamic Programming 101
Step 1: Spot overlapping subproblems
Step 2: Cry a little
Step 3: Write recursion like a hero
Step 4: Memoize it like a pro
Step 5: Tabulate like an engineer
Step 6: Never talk about recursion again
#DynamicProgramming#AlgoLife
For leaderboard not killing the app I would have a redis sorted set DS for the top 10k players.
I would tradeoff speed over near perfect accuracy with a eventual consistency model with background DB sync.
For scaling reads, I would shard based on game server region.
Game all day!
Building a mobile game for 10M players. You need a real-time leaderboard for the top 10k.
Your SELECT * FROM scores ORDER BY score DESC LIMIT 10000 query runs thousands of times/sec with 1M concurrents.
Your DB CPU hits 100%, and the game lags for everyone.
How do you design a leaderboard that can handle this scale?
This could've happened even with #Rust
This does not scream memory corruption it screams “I trusted that Option blindly and got None’d to death.”
Rust won’t let you have buffer overflows, but it will sit back and watch you unwrap None like it’s popcorn worthy.🍿🦀
Logical error!