frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Bit-packed segmented prime sieve in Rust, 32KB working memory, 0 deps

3•whisprer•2h ago
Started with a hyper-compact C++ bit-packed sieve — months of whittling it down to ~9 lines of raw bit manipulation. One bit per odd number, Brian Kernighan's bit trick for extraction, hardware tzcnt intrinsics. Then I ported it to Rust.

The borrow checker had opinions. You can't .filter() over a bit array (immutable borrow) and .for_each() mutate it simultaneously. Fair enough — explicit loops for the sieve phase, iterators for collection. Same assembly output, provably safe. Along the way I caught two assertion bugs the sieve was too correct to trigger (off-by-one on the 10,001st prime; 499,999 is composite, not prime).

The flat sieve hit a wall at ~10M — the bit array exceeds L1 cache (32KB) and every sieving pass thrashes. So I built a segmented version: bootstrap sieving primes via flat sieve up to √n, then process the full range in 32KB L1-sized segments. One buffer, reused, never leaves cache.

Results (single-threaded, 25 iterations, cross-verified against primal crate):

  n=500K:   ~440µs, 30KB sieve mem
  n=10M:    ~10ms, 32KB sieve mem
  n=50M:    ~52ms, 32KB sieve mem (flat: ~67ms)
  n=100M:   ~137ms, 32KB sieve mem (flat: ~190ms)
Compared to the primal crate (Rust's best-in-class), raw speed is ~2x behind — primal uses wheel-30 factorisation which skips multiples of 2, 3, and 5. This sieve only skips evens. But memory is where it wins: 187x less sieve working memory than primal at n=50M (32KB vs 6MB), and a tighter result vector from prime-counting pre-allocation.

The target use case is embedded/constrained: ESP32 nodes, Raspberry Pi Zeros, distributed timing networks where every KB matters. It's also a clean reference implementation — one file, zero dependencies, compiles with a single rustc invocation.

Single file. No Cargo. No crates. Just:

  rustc -C opt-level=3 -C target-cpu=native primer.rs && ./primer
Code, benchmarks, borrow checker writeup, and a full development narrative are all in the repo.

Confronting Evil (2016)

https://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1017&context=psrl
1•joebig•1m ago•0 comments

From PDF to .LBR: Using Deep Think to Write Custom CAD Parts

https://blog.adafruit.com/2026/02/14/from-pdf-to-lbr-using-deep-think-to-write-custom-cad-parts/
1•zdw•4m ago•0 comments

Archimedes: Fulcrum of Science

https://www.lrb.co.uk/the-paper/v48/n03/claire-hall/maths-is-second-best
1•mitchbob•5m ago•1 comments

Show HN: ScreenKite: Free alternative to Screen Studio with 4x export speed

https://www.screenkite.com/en
3•imWildCat•8m ago•0 comments

One line of code, 102 blocked threads

https://medium.com/@nik6/a-deep-dive-into-classloader-contention-in-java-a0415039b0c1
1•birdculture•12m ago•0 comments

Apple patches ancient iOS versions to keep iMessage, FaceTime working

https://arstechnica.com/gadgets/2026/01/apple-patches-ancient-ios-versions-to-keep-imessage-facet...
1•colinprince•12m ago•0 comments

Depressive Realism

https://en.wikipedia.org/wiki/Depressive_realism
1•ksec•14m ago•0 comments

The Cab Ride That Circled the Earth

https://www.kentnerburnauthor.com/disc.htm
1•me_smith•15m ago•1 comments

Don't ban teenagers from social media

https://www.economist.com/leaders/2026/02/12/dont-ban-teenagers-from-social-media
1•ianrahman•16m ago•0 comments

AI Bot Traffic to Sites Is Rising Rapidly and Could Change the Nature of the Web

https://www.inc.com/chris-morris/ai-bot-traffic-to-websites-is-rising-rapidly-it-could-change-the...
3•giuliomagnifico•17m ago•0 comments

Pg_stat_ch: Postgres extension to ship every PG metric to ClickHouse

https://clickhouse.com/blog/pg_stat_ch-postgres-extension-stats-to-clickhouse
1•saisrirampur•17m ago•0 comments

Is End-to-End Encryption Optional for Large Groups? – Dhole Moments

https://soatok.blog/2026/02/14/is-end-to-end-encryption-optional-for-large-groups/
1•cratermoon•20m ago•0 comments

Hamming, "You and Your Research" (1995) [video]

https://www.youtube.com/watch?v=a1zDuOPkMSw
1•criemen•21m ago•0 comments

Alignment at its Weakest Link

https://futurisold.github.io/2026-02-14-alignment-at-its-weakest-link/
1•futurisold•22m ago•0 comments

America Fell Out of Love with the Sedan. Detroit Wants to Bring It Back

https://www.wsj.com/business/autos/sedans-cars-trucks-detroit-afb034ee
1•santix•24m ago•0 comments

ClawdReview – OpenReview for AI Agents

5•mingtianzhang•25m ago•0 comments

UpScrolled is currently unavailable for download on the Play Store

https://twitter.com/realUpScrolled/status/2022696096041177563
2•LordAtlas•26m ago•0 comments

GitHub acknowledged open source's spam crisis

https://medium.com/reading-sh/github-finally-acknowledged-open-sources-spam-crisis-a32b22a6699c
1•reg_dunlop•26m ago•0 comments

Show HN: Buildcage – Restrict outbound network access during Docker builds

https://github.com/dash14/buildcage
1•dash14•26m ago•1 comments

Show HN: 1Hash/Sec/Node PoW During A/V Calls, No Parallel Mining and P2P Telecom

https://grahambell.io/mvp/
1•HurairahShamsi•26m ago•1 comments

Show HN: Arcmark – macOS bookmark manager that attaches to browser as sidebar

https://github.com/Geek-1001/arcmark
3•ahmed_sulajman•27m ago•0 comments

Stoat removes all LLM-generated code following user criticism

https://github.com/orgs/stoatchat/discussions/1022
13•ashleyn•28m ago•2 comments

Who Writes Most Complexly? Shtetl Optimized vs. Simon Willison vs. Alex Harri

https://juleshenry.github.io/blog/2026/02/14/Shtetl-Optimization
2•juleshenry•29m ago•0 comments

Show HN: Chuk.chat – Privacy-first AI chat with multiple models

https://chuk.chat/en/
1•chukfinley2•30m ago•0 comments

PascalABC.net

https://pascalabc.net:443/en
2•andsoitis•30m ago•0 comments

Interop 2026

https://webkit.org/blog/17818/announcing-interop-2026/
2•ksec•30m ago•0 comments

The foundation problem: How a lack of accountability is destroying cybersecurity

https://www.csoonline.com/article/4131530/the-foundation-problem-how-a-lack-of-accountability-is-...
1•ungreased0675•30m ago•2 comments

What's Real in "Borat" (2006)

http://www.salon.com/ent/feature/2006/11/10/guide_to_borat/index.html
1•rolph•31m ago•2 comments

Amsterdam Compiler Kit

https://github.com/davidgiven/ack
2•andsoitis•32m ago•0 comments

The AI Industry Just Spent $100M Teaching America Not to Trust AI

https://medium.com/@emiliesydneysmith1/the-ai-industry-just-spent-100-million-teaching-america-no...
3•EmilieSS1•32m ago•0 comments