frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: LoopMix128 – Fast C PRNG (.46ns), 2^128 Period, BigCrush/PractRand Pass

https://github.com/danielcota/LoopMix128
27•the_othernet•3h ago
LoopMix128 is a fast C PRNG I wrote for non-cryptographic tasks.

GitHub (MIT): https://github.com/danielcota/LoopMix128

Highlights:

* ~0.37 ns/value (GCC 11.4, -O3 -march=native), 98% faster than xoroshiro128++ and PCG64.

* Passes TestU01 BigCrush & PractRand (32TB).

* Guaranteed 2^128 period.

* Proven injective (192-bit state) via Z3 SMT solver; allows parallel streams.

* Core requires only stdint.h.

Seeking feedback on design, use cases, or further testing.

Comments

zX41ZdbW•2h ago
Also interesting to include PCG for comparison.
the_othernet•1h ago
Just added to benchmark.c in the Github. Performance is comparable to xoroshiro128++.
zX41ZdbW•2h ago
> after he fell down the PRNG rabbit-hole by circumstance

Curious to learn more about the circumstance :)

the_othernet•1h ago
I have an offline poker app, and a user asked me what the algorithm was to generate the random numbers. That was a month ago. :)
kstrauser•1h ago
I feel this in my bones. I’m not qualified to comment on the quality of the result, but I certainly appreciate and identify with the circumstances.
jrapdx3•2h ago
From the Github repo: "Created by Daniel Cota after he fell down the PRNG rabbit-hole by circumstance." I understand how that can happen.

Wondering how this PRNG compares to PCG PRNGs that also claim to be "simple fast space-efficient statistically good algorithms" and "hard to predict" [0].

In any case, it's good to see the excellent work being accomplished in this space.

[0] https://www.pcg-random.org/

the_othernet•1h ago
I just added PGC64 to benchmark.c in the Github. PCG64 speed looks to be about the same as xoroshiro128++.
jrapdx3•8m ago
Yes, indeed it is. While these PRNGs are all pretty decent, improvements are always welcome. Most impressive is the utter simplicity of the algorithms, including LoopMix128. Definitely makes it easy to incorporate high-quality PRNG functionality in applications.
RainyDayTmrw•1h ago
When do people both want (PRNG performance is a measurable fraction of total program performance) and can use (no security constraints) an extremely fast PRNG?
986aignan•1h ago
Monte Carlo simulations would be the obvious example.
pierrec•1h ago
It's common in graphics and audio programming. In audio, maybe you're synthesizing noise or any of the myriad synthesis techniques that require noise. In graphics you have lighting, textures, etc that can use this. And when you're doing something every audio sample or every pixel, "extremely fast" is desirable. The question of whether to use a pre-rendered lookup table or a fast algorithm often comes up (and has no universal answer... though I always go for the latter)
aappleby•1h ago
MurmurHash/SMHasher author here. While I don't doubt this passes BigCrush etc, I do find it very surprising that it does.

The state update function is effectively "a = rotate(a, constant) + b; b = rotate(b, constant) + constant;" and the output derivation is "output = (a + b) * constant".

That update function is _barely_ nonlinear, and the output derivation is linear. The output would probably be slightly better as "(a ^ b) * constant".

The slow_loop thing to guarantee 2^128 period is probably not needed - anyone with an application that cares about a period that high is probably going to choose a more robust generator (a few rounds of hardware-accelerated AES in counter mode is your best bet there)

The use of the Z3 prover is neat and I should read up on that more.

aappleby•1h ago
I'm not sure that the claim "the mix function is injective" is sufficient to support the claim "The period is at least 2^128". If the mix is reversible then it forms a permutation on 2^192, but that does not imply that it forms a single cyclic permutation.

For example, if f(0) = 1 and f(1) = 0, even if the rest of f's domain is injective the period of f is still only 2 when the initial value is 0 or 1.

the_othernet•1h ago
I wasn't able to analyze the cyclic behavior of the mix directly, but for the purpose of minimal period only fast_loop and slow_loop are used (as a 128bit counter).
the_othernet•1h ago
Hello! Awesome work on your hashing by the way!

When iterating I first tried to make fast_loop as random as possible by trying all possible rotational values and then having each option tested in PractRand 1000 times from 256M to 8GB. There was a wide range of performance by rotation. 47 was the best (for the GR constant) and resulted in the most tests being passed. The goal was a stronger than normal core for the PRNG that could feed actively into mix.

I found the multiplication to be necessary for passing PractRand and BigCrush with the state mixing as posted.

I had a variant which assigned mix as rotate(mix,constant) + (mix^fast_mix). That would pass cleanly with mix directly outputted (with no multiplication) - but I couldn’t get Z3 prover to show injectivity so I decided to go with the posted route.

EU abandons ePrivacy reform to boost AI competitiveness

https://techcrunch.com/2025/02/12/eu-abandons-eprivacy-reform-as-bloc-shifts-focus-to-competitiveness-and-fostering-data-access-for-ai/
3•bit_qntum•3m ago•0 comments

Senators probe Google–Anthropic, Microsoft–OpenAI deals over antitrust concerns

https://www.computerworld.com/article/3958091/senators-probe-google-anthropic-microsoft-openai-deals-over-antitrust-concerns.html
4•byte-bolter•3m ago•0 comments

Scoring the European Citizen in the AI Era

https://arxiv.org/abs/2505.02791
3•gray_amps•6m ago•0 comments

Rubicon: Precise Microarchitectural Attacks with Page-Granular Massaging

https://comsec.ethz.ch/research/dram/rubicon/
1•pabs3•7m ago•0 comments

The Little Kindgom (1982)

https://www.folklore.org/The_Little_Kingdom.html
1•kristianp•8m ago•0 comments

Ireland given two months to implement hate speech laws or face action from EU

https://www.thejournal.ie/ireland-given-two-months-to-start-implementing-hate-speech-laws-6697853-May2025/
1•like_any_other•9m ago•0 comments

This is Water by David Foster Wallace

https://fs.blog/david-foster-wallace-this-is-water/
1•alihm•12m ago•0 comments

Show HN: CXcompress v1.0.0-beta: fast lossless pre-procecssing text compressor

https://github.com/seccode/CXcompress
1•s3cfast•14m ago•0 comments

Wikipedia: Lamest Edit Wars

https://en.wikipedia.org/wiki/Wikipedia:Lamest_edit_wars
1•jsheard•16m ago•1 comments

Coding a Web Server in 25 Lines (2024) [video]

https://www.youtube.com/watch?v=7GBlCinu9yg
1•indigodaddy•17m ago•0 comments

Where does the ginseng in your tea come from? Graphic memoir explains the trade

https://www.npr.org/2025/05/09/nx-s1-5137011/ginseng-roots-craig-thompson-blankets
1•srameshc•23m ago•0 comments

Top 5 New Artificial Intelligence Innovations in 2025

https://wilnickmagazine.com/5-new-artificial-intelligence-in-2025/
1•Wilnick•27m ago•0 comments

Show HN: Swytch – A lightweight, alternative web framework in C#

https://github.com/Gwali-1/Swytch
1•Gwali-Gwali•32m ago•0 comments

Elizabeth Holmes's Partner Has a New Blood-Testing Startup

https://www.nytimes.com/2025/05/10/business/elizabeth-holmes-partner-blood-testing-startup.html
1•lxm•32m ago•0 comments

Police, researchers disrupt botnet comprising EOL residential routers

https://www.bleepingcomputer.com/news/security/police-dismantles-botnet-selling-hacked-routers-as-residential-proxies/
2•heresie-dabord•38m ago•0 comments

Denoro, a CLI tool to explore Deno KV local databases

https://davrodpin.github.io/denoro/
1•davrodpin•41m ago•1 comments

UK plans to end 'failed free market experiment' in immigration

https://www.reuters.com/world/uk/uk-plans-end-failed-free-market-experiment-immigration-2025-05-10/
2•thunderbong•43m ago•0 comments

Made In China 2025

https://en.wikipedia.org/wiki/Made_in_China_2025
3•kaycebasques•45m ago•0 comments

Scraipe: AI Scraping and Analysis Framework

https://github.com/SnpM/scraipe
1•snpm•46m ago•1 comments

Ask HN: What do you actually do with your wearable health data?

1•dzohrob•47m ago•0 comments

Zero ships from China are bound for California's top ports

https://www.cnn.com/2025/05/10/business/zero-ships-china-trade-ports-pandemic
7•Anon84•48m ago•0 comments

Craigslist revenue drops to 300M, one-third of 2018 total

https://www.jobboardhive.com/2025/04/03/craigslist-revenue-traffic-drops-again-one-third-of-2018-total/
2•walterbell•50m ago•1 comments

Why I didn't attend PyCon Australia 2024

https://www.lesinskis.com/pyconau-2024.html
6•qmgcount•59m ago•1 comments

No One Was Talking

https://space.tcsenpai.com/no-one-was-talking-emergent-discourse-between-autonomous-language-models-in-a-reflexive-test-of-meaning-ethics-and-error/
1•erdaniels•59m ago•1 comments

Fandom Sells Giant Bomb to Independent Creators

https://about.fandom.com/news/fandom-sells-giant-bomb-to-independent-creators
1•minimaxir•1h ago•0 comments

The Substance: Pre-Release Piracy Made People More Eager to Visit the Cinema

https://torrentfreak.com/the-substance-pre-release-piracy-made-people-more-eager-to-visit-the-cinema-250510/
3•hn_acker•1h ago•0 comments

Elizabeth Holmes Partner Rakes in Millions for New Blood Testing Machine

https://www.newsweek.com/elizabeth-holmes-partner-rakes-millions-new-blood-test-machine-2070573
2•Anon84•1h ago•1 comments

Lamps [video]

https://www.youtube.com/watch?v=PEJnsBeQ_Y8
1•nativeit•1h ago•1 comments

Trump Officials Seek to Bring First White Afrikaners to U.S. as Refugees (Cont)

https://www.nytimes.com/2025/05/09/world/africa/trump-afrikaner-refugees.html
5•whack•1h ago•3 comments

Examining a Copyright Claim from Copytrack

https://www.bentasker.co.uk/posts/blog/general/copytrack-sent-me-a-copyright-claim.html
2•marbu•1h ago•0 comments