The best Hacker News stories from All from the past day
Latest posts:
"Firefox added [ad tracking] and has already turned it on without asking you"
Show HN: 30ms latency screen sharing in Rust
Disney's Internal Slack Breached? NullBulge Leaks 1.1 TiB of Data
Jelly Star – The Smallest Android 13 Smartphone
Jelly Star – The Smallest Android 13 Smartphone
Crafting Interpreters
Use a work journal
So you want to rent an NVIDIA H100 cluster? 2024 Consumer Guide
Using S3 as a Container Registry
Windows NT for Power Macintosh
Tau: Open-source PaaS – A self-hosted Vercel / Netlify / Cloudflare alternative
Tau: Open-source PaaS – A self-hosted Vercel / Netlify / Cloudflare alternative
As an Employee, You Are Disposable (2023)
Free-threaded CPython is ready to experiment with
Free-threaded CPython is ready to experiment with
AT&T says criminals stole phone records of 'nearly all' customers in data breach
AT&T says criminals stole phone records of 'nearly all' customers in data breach
Engineering principles for building financial systems
Show HN: Dut – a fast Linux disk usage calculator
"dut" is a disk usage calculator that I wrote a couple months ago in C. It is multi-threaded, making it one of the fastest such programs. It beats normal "du" in all cases, and beats all other similar programs when Linux's caches are warm (so, not on the first run). I wrote "dut" as a challenge to beat similar programs that I used a lot, namely pdu[1] and dust[2].<p>"dut" displays a tree of the biggest things under your current directory, and it also shows the size of hard-links under each directory as well. The hard-link tallying was inspired by ncdu[3], but I don't like how unintuitive the readout is. Anyone have ideas for a better format?<p>There's installation instructions in the README. dut is a single source file, so you only need to download it and copy-paste the compiler command, and then copy somewhere on your path like /usr/local/bin.<p>I went through a few different approaches writing it, and you can see most of them in the git history. At the core of the program is a datastructure that holds the directories that still need to be traversed, and binary heaps to hold statted files and directories. I had started off using C++ std::queues with mutexes, but the performance was awful, so I took it as a learning opportunity and wrote all the datastructures from scratch. That was the hardest part of the program to get right.<p>These are the other techniques I used to improve performance:<p>* Using fstatat(2) with the parent directory's fd instead of lstat(2) with an absolute path. (10-15% performance increase)<p>* Using statx(2) instead of fstatat. (perf showed fstatat running statx code in the kernel). (10% performance increase)<p>* Using getdents(2) to get directory contents instead of opendir/readdir/closedir. (also around 10%)<p>* Limiting inter-thread communication. I originally had fs-traversal results accumulated in a shared binary heap, but giving each thread a binary-heap and then merging them all at the end was faster.<p>I couldn't find any information online about fstatat and statx being significantly faster than plain old stat, so maybe this info will help someone in the future.<p>[1]: <a href="https://github.com/KSXGitHub/parallel-disk-usage">https://github.com/KSXGitHub/parallel-disk-usage</a><p>[2]: <a href="https://github.com/bootandy/dust">https://github.com/bootandy/dust</a><p>[3]: <a href="https://dev.yorhel.nl/doc/ncdu2" rel="nofollow">https://dev.yorhel.nl/doc/ncdu2</a>, see "Shared Links"
Second factor SMS: Worse than its reputation