frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Performance Improvements in Libffi

https://atgreen.github.io/repl-yell/posts/libffi-plan-cache/
25•atgreen•2d ago

Comments

rurban•2d ago
Oh, I thought he does this already. Why was there a prepare, when it doesnt prepare the arg decoding.
atgreen•1d ago
TBH, the complexity of this step grew over time, and the overhead snuck up on us. The prep step does useful work (eg. determine stack space requirements). It's just that we don't have to do it again.

Something I should have mentioned is that we could have avoided the new APIs if only there was space in the ffi_cif to stash a plan pointer. And I didn't want to break ABIs for this.

tadfisher•1d ago
Can we AOT-compile stubs instead of interpreting or JIT-compiling? I feel like most FFI users would call static, well-defined functions.
atgreen•1d ago
Yes, that's part of what was done here. So, create a plan, and then for some subset of plans, create AOT-compiled templates. The analogies are: a) original implementation is like interpreting via walking a syntax tree b) building/caching an execution plan is like interpreting by executing bytecode generated from the syntax tree c) using an AOT-compiled template is like execution from qemu's old TCG template system But we only do (c) for a popular subset of function signatures. The biggest win was (b), but (c) is still an improvement over (b).
quotemstr•1h ago
I'd measure twice before cutting. Almost everyone not deep into cross-language interop and VM design intuits, incorrectly, that FFI mechanisms themselves drive interop costs. In practice, it's almost never the case. While, in principle, compiling a libffi signature to native code could be a win, doing so matters a lot less often than you think.

Keep in mind that optimizing the call doesn't optimize the marshaling: even with an AOT-compiled FFI trampoline, if you're, say, sending a string from one place to another, you usually need to transform the string in some manner (copy it, change encoding, add/remove length prefixes, etc.) and JITing the libffi parameter passing won't help you do the string stuff any faster.

In fact, trying to AOT the connections can make your program worse, both by bloating it (causing some likely small, but still, cache pressure) and by complicating your build and deployment process.

libffi bytecode is good. I wouldn't bother with native code until I had a profile in hand showing the bytecode to be the bottleneck, and even then, I'd check it a three or four times to make sure I didn't get the profiling wrong. FFI is just seldom the problem in real-world systems.

quotemstr•1h ago
Bytecode is an awesome trick and gets used in a surprising number of situations. In Windows COM, for example, (for IPC and serialization), stubs and proxies do their marshaling by interpreting a small bytecode generated from type and signature descriptions. You end up with an artifact smaller and more convenient than AOT-compiled native code and it doesn't hurt performance in any practical way.

Notably, the COM bytecode covers not only procedure-level argument-passing, but data structure transformations themselves. It's a nice setup.

Jerry's Map

http://www.jerrysmap.com/the-map
115•turtleyacht•1h ago•15 comments

Anthropic updates their terms to verify age or identity

https://www.anthropic.com/legal/privacy
44•arunc•23m ago•10 comments

Swift Package Index joins Apple

https://swiftpackageindex.com/blog/swift-package-index-joins-apple
88•JDevlieghere•2h ago•25 comments

F3

https://github.com/future-file-format/f3
489•tosh•3h ago•117 comments

Show HN: TikZ Editor – WYSIWYG editor for figures in LaTeX

https://tikz.dev/editor/
268•DominikPeters•5h ago•55 comments

The worthlessness of Vitamin D is mildly exaggerated

https://dynomight.net/vitamin-d/
68•surprisetalk•3h ago•36 comments

Unlimited OCR: One-shot long-horizon parsing

https://github.com/baidu/Unlimited-OCR
383•ingve•8h ago•91 comments

San Diego photologs from the 1970s

https://www.beautifulpublicdata.com/san-diego-photologs-from-the-1970s/
110•jonathanmkeegan•3h ago•26 comments

Five monitors on a Commodore 128 [video]

https://www.youtube.com/watch?v=ul5hC3PY1Yg
72•EvanAnderson•1d ago•13 comments

FUTO Swipe – A new swipe typing model

https://swipe.futo.tech/
25•futohq•2h ago•3 comments

Lift4D: Harmonizing Single-View 3D Estimation for 4D Reconstruction In-the-Wild

https://lift4d.github.io/
86•ilreb•5h ago•7 comments

The Coming Loop

https://lucumr.pocoo.org/2026/6/23/the-coming-loop/
228•ingve•9h ago•181 comments

The deadly rise of giant trucks and SUVs

https://www.nytimes.com/interactive/2026/06/21/us/trucks-suv-pedestrian-crashes.html
168•xnx•1d ago•337 comments

Samsung demonstrates 3D stacked FETs with triple nanosheet channels at 42nm

https://semiconductor.samsung.com/news-events/tech-blog/from-gaa-to-3d-stacked-fet-expanding-the-...
52•its_ajseven•4d ago•20 comments

Claude Tag

https://www.anthropic.com/news/introducing-claude-tag
157•adocomplete•2h ago•83 comments

AI Hiring Tools Yield Racial Bias and Systemic Rejection; 26% Black & 15% Asian

https://hai.stanford.edu/news/ai-hiring-tools-can-yield-racial-bias-and-systemic-rejection
18•sizzle•1h ago•4 comments

Performance Improvements in Libffi

https://atgreen.github.io/repl-yell/posts/libffi-plan-cache/
26•atgreen•2d ago•6 comments

Plotnine

https://plotnine.org/
234•tosh•4d ago•69 comments

Mistral OCR 4

https://mistral.ai/news/ocr-4/
354•meetpateltech•6h ago•90 comments

Solving Wordle using information theory

https://www.binghamton.edu/news/story/6327/s-m-a-r-t-these-researchers-used-math-to-crack-wordle
37•hhs•2d ago•46 comments

MSG Made Dossier on Activists Who Opposed Facial Recognition

https://www.404media.co/madison-square-garden-made-dossier-on-activists-who-opposed-facial-recogn...
247•cdrnsf•6h ago•69 comments

Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

https://github.com/ilbertt/bun-sqlgen
49•ilbert•5h ago•23 comments

The Low-Tech AI of Elden Ring

https://nega.tv/posts/low-tech-ai-of-elden-ring.html
66•g0xA52A2A•8h ago•37 comments

Elevated error rate across multiple models

https://status.claude.com/incidents/jbhf20wjmzrf
183•rob•5h ago•238 comments

Finding the best dog treat with statistics

https://www.wespiser.com/posts/2026-06-19-best-dog-treat.html
117•wespiser_2018•1d ago•53 comments

Will It Mythos?

https://swelljoe.com/post/will-it-mythos/
290•mindingnever•15h ago•210 comments

VibeThinker: 3B param model that beats Opus 4.5 on reasoning with novel SFT+GRPO

https://arxiv.org/abs/2606.16140
356•timhigins•18h ago•185 comments

Modal Auto Endpoints: Optimized inference you own

https://modal.com/blog/introducing-auto-endpoints
11•handfuloflight•1h ago•1 comments

What we call "age verification" is actually mass surveillance

https://pluralistic.net/2026/06/23/destroy-the-village/
622•hn_acker•6h ago•331 comments

Show HN: Treedocs: Documentation that automatically checks for staleness

https://dandylyons.github.io/treedocs/
33•DandyLyons•5h ago•17 comments