So I installed the other day on my small vps and during a load test I found out that it takes up more than 60% of the CPU during high load. I use(d) it to block annoying attempts to open random php admin pages (I don't even use PHP).

Figured out it's written in python and actually expected such a popular basic tool to be written in C for best performance...

So I started writing a mini clone in and it can handle 300,000 lines/sec on 1 cpu core in first tests.

Rewrote my day 6 challenge in from building an object tree with Rc + RefCell to a much simpler version that only uses a string to string mapping for the tree traversal.
Also threw in FNV as HashMap hasher for an extra speed bump. The difference is huge.

Part 1 is 61% faster (598 ΞΌs down to 233 ΞΌs).
Part 2 is 97% faster (40 ms down to 1 ms).

Finished challenge 6 today and had to fight with the borrow checker a lot.

Everything worked in the end, but sharing mutable references in rust is quite a messy thing. Now my type definition looks like

Option<Rc<RefCell<Orbit>>>

And my code is full of

orbit.borrow().parent.as_ref().unwrap().clone();

I wonder if there is a cleaner way πŸ€”...

Great tool if you build your own procedural macros in and want to verify the output. Also interesting when using 3rd party derives or macros.

github.com/dtolnay/cargo-expan

Was doing my first work with 's procedural macros last week. Awesome AST manipulation techniques and actually quite easy to use.
Despite its high learning curve, it's a breeze to work with, unlike in other languages (looking at you Java and your annotation processors).

Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!