(b

(bits) of a Libc, Optimized for Wasm

Hacker News

(bits) of a Libc, Optimized for Wasm

I make a no-CGO Go SQLite driver, by compiling the amalgamation to Wasm, then loading the result with wazero (a CGO-free Wasm runtime). To compile SQLite, I use wasi-sdk, which uses wasi-libc, which is based on musl. It's been said that musl is slow(er than glibc), which is true, to a point. musl uses SWAR on a size_t to implement various functions in string.h. This is fine, except size_t is just 32-bit on Wasm. I found that implementing a few of those functions with Wasm SIMD128 can make them go around 4x faster. Other functions don't even use SWAR; redoing those can make them 16x faster. Smooth sort also has trouble pulling its own weight; a Shell sort seems both simpler and faster, while similarly avoiding recursion, allocations and the addressable stack. I found that using SIMD intrinsics (rather than SWAR) makes it easier to avoid UB, but the code would definitely benefit from more eyeballs. See this for some benchmarks on both x86-64 and Aarch64: https://github.com/ncruces/go-sqlite3/actions/runs/145169318...

Share card

Actual performance

78points
16comments
Made the leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: using, code · Missing: mac, agents, macos
69%69% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: io · Missing: https docs, excited, just released
69%69% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Missing: mobile apps, ios, personal
43%43% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
42%42% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Indie HackersIH features products with proven revenue · Missing: supports, reddit linkedin, podcasting
37%37% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
15%15% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
1%1% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

Mo
Mobile optimized Arguman48%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Mobile optimized Arguman

Hacker News3
Gr
GruntStart (Grunt+H5BP+jQuery+Modernizr) - Optimized Development55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

GruntStart (Grunt+H5BP+jQuery+Modernizr) - Optimized Development

Hacker News3
Travelized
Travelized25%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Optimized Travel

Product Hunt+9
pr
pry-rescue — workflow-optimized debugging for ruby55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

pry-rescue — workflow-optimized debugging for ruby

Hacker News69
Ho
How Optimized Threaded Pagination Works50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

How Optimized Threaded Pagination Works

Hacker News5
Ja
Jax and Flax LLMs – Transformer Implementations Optimized for TPUs70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Jax and Flax LLMs – Transformer Implementations Optimized for TPUs

Hacker News3
An
An optimized and ergonomic image annotation platform50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

An optimized and ergonomic image annotation platform

Hacker News3
UB
UBPE – a universal BPE tokenizer, optimized and rethought54%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

UBPE – a universal BPE tokenizer, optimized and rethought

Hacker News1
Go
Go version of HighwayHash with optimized assembly implementations59%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Go version of HighwayHash with optimized assembly implementations

Hacker News48
Mg
Mgo: build a single Go binary optimized for all GOAMD64 variants43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Mgo: build a single Go binary optimized for all GOAMD64 variants

Hacker News2