frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Show HN: MyRise Coach – AI-powered growth platform with 8 proven methodologies

https://myrisecoach.com/en
1•iaiuse•1m ago•0 comments

Burn Rate hot sauce (wrapped in a real $100 bill, for $13.99)

https://burnrate.cash/
1•nycdatasci•6m ago•0 comments

Pico-Banana-400K: A Large-Scale Dataset for Text-Guided Image Editing

https://arxiv.org/abs/2510.19808
1•salkahfi•7m ago•0 comments

South Korea's fishermen keep dying. Is climate change to blame?

https://www.bbc.com/news/articles/cvg924nrgd3o
1•blondie9x•11m ago•0 comments

Some Notes on Nix Flakes

https://jvns.ca/blog/2023/11/11/notes-on-nix-flakes/
1•n3t•13m ago•1 comments

Treasure Trove of Shipwrecks Along China's Coast

https://www.smithsonianmag.com/history/treasure-trove-of-shipwrecks-along-chinas-coast-reveals-ho...
1•Brajeshwar•18m ago•0 comments

Astronomers discover skyscraper-size asteroid hidden in sun's glare

https://www.livescience.com/space/asteroids/astronomers-discover-skyscraper-size-asteroid-hidden-...
1•Brajeshwar•18m ago•0 comments

AI is changing our understanding of earthquakes

https://knowablemagazine.org/content/article/physical-world/2025/ai-is-changing-understanding-of-...
1•Brajeshwar•19m ago•0 comments

Interest Survey: Copilot for Exchange Server (On-Premises)

https://techcommunity.microsoft.com/blog/exchange/interest-survey-copilot-for-exchange-server-on-...
1•asimops•22m ago•0 comments

If AI "slop" scares you, your PR reviews are broken

https://www.pcloadletter.dev/blog/pr-review-ai-slop/
1•ronbenton•27m ago•0 comments

Detection firm finds 82% of herbal remedy books on Amazon 'likely written' by AI

https://www.theguardian.com/books/2025/oct/22/detection-firm-finds-82-of-herbal-remedy-books-on-a...
2•pogue•28m ago•1 comments

Paternal exercise confers endurance to offspring through sperm microRNAs

https://www.cell.com/cell-metabolism/fulltext/S1550-4131(25)00388-2
3•PaulHoule•29m ago•0 comments

Blind User's Experience with Smart Glasses

https://abilitymagazine.com/meta-ray-bans-blind-users-experience-with-smart-glasses/
2•geox•31m ago•0 comments

Alaska Airlines, experiencing an IT outage, issues a ground stop

https://twitter.com/AlaskaAirNews/status/1981501224605405238
2•gnabgib•32m ago•1 comments

Unicode Footguns in Python

https://pythonkoans.substack.com/p/koan-15-the-invisible-ink
2•meander_water•33m ago•0 comments

Boa release v0.21 – a new release of Boa, a JavaScript engine written in Rust

https://boajs.dev/blog/2025/10/22/boa-release-21
1•birdculture•36m ago•0 comments

First Verifiable AI Architecture Analysis – Zero Source Files Read

https://github.com/mirzahusadzic/cogx
1•mirza_husadzic•37m ago•1 comments

Finding a Successor to the FHS

https://lwn.net/Articles/1032947/
2•baobun•38m ago•0 comments

Alaska Airlines issues temporary ground stop

https://mynorthwest.com/chokepoints/alaska-airlines-3/4146461
1•tobinfekkes•38m ago•0 comments

Against the Machine: On the Unmaking of Humanity – Paul Kingsnorth

https://www.newstatesman.com/culture/2025/10/the-prophecies-of-paul-kingsnorth
1•pseudolus•40m ago•0 comments

MAINdial – Find any landline instantly with GPS/AI

https://dial-wise-60854cc8.base44.app/
1•Conceiver•41m ago•0 comments

Two federal judges say use of AI led to errors in US court rulings

https://www.channelnewsasia.com/business/two-federal-judges-say-use-ai-led-errors-in-us-court-rul...
4•bbzjk7•42m ago•0 comments

Is Terminal Lucidity Real?

https://preservinghope.substack.com/p/is-terminal-lucidity-real
2•paulpauper•43m ago•0 comments

The System Skill Pattern

https://www.shruggingface.com/blog/the-system-skill-pattern
3•mercat•54m ago•1 comments

Counter-Strike's player economy is in a multi-billion dollar freefall

https://www.polygon.com/counter-strike-cs-player-economy-multi-billion-dollar-freefall/
20•perihelions•1h ago•3 comments

Emacs: Write to Minibuffer

https://stackoverflow.com/questions/36118899/inserting-text-into-an-active-minibuffer
3•gfalcao•1h ago•0 comments

Mario Creator Shigeru Miyamoto Might Be Right About the Future of Gaming

https://comicbook.com/gaming/feature/shigeru-miyamoto-gaming-future/
3•mikhael•1h ago•0 comments

Antidepressants: Physical side-effects vary depending on the drug type

https://theconversation.com/antidepressants-physical-side-effects-vary-depending-on-the-drug-type...
1•gmays•1h ago•0 comments

American e-waste is causing a 'hidden tsunami' in Southeast Asia, report says

https://www.nbcnews.com/world/asia/american-e-waste-causing-hidden-tsunami-southeast-asia-report-...
3•clumsysmurf•1h ago•1 comments

AI Sidebar Spoofing Puts ChatGPT Atlas, Perplexity Comet, Other Browsers at Risk

https://www.securityweek.com/ai-sidebar-spoofing-puts-chatgpt-atlas-perplexity-comet-and-other-br...
3•botanicals6•1h ago•0 comments
Open in hackernews

How memory maps (mmap) deliver faster file access in Go

https://info.varnish-software.com/blog/how-memory-maps-mmap-deliver-25x-faster-file-access-in-go
60•ingve•3h ago

Comments

nawgz•2h ago
Sounds interesting. Why wouldn’t the OS itself default to this behavior? Could it fall apart under load, or is it just not important enough to replace the legacy code relying on it?
trenchpilgrim•2h ago
1. mmap was added to Unix later by Sun, it wasn't in the original Unix

2. As the article points out mmap is very fast for reading huge amounts of data but is a lot slower at other file operations. For reading smallish files, which is the majority of calls most software will make to the filesystem, the regular file syscalls are better.

3. If you're on a modern Linux you might be better off with io_uring than mmap.

scottlamb•1h ago
All true, and it's not just performance either. The API is just different. mmap data can change at any time. In fact, if the file shrinks, access to a formerly valid region of memory has behavior that is unspecified by the Single Unix Specification. (On Linux, it causes a SIGBUS if you access a page that is entirely invalid; bytes within the last page after the last valid byte probably are zeros or something? unsure.)

In theory I suppose you could have a libc that mostly emulates read() and write() calls on files [1] with memcpy() on mmap()ed regions. But I don't think it'd be quite right. For one thing, that read() behavior after shrink would be a source of error.

Higher-level APIs might be more free to do things with either mmap or read/write.

[1] just on files; so it'd have to track which file descriptors are files as opposed to sockets/pipes/etc, maintaining the cached lengths and mmap()ed regions and such. libc doesn't normally do that, and it'd go badly if you bypass it with direct system calls.

nteon•2h ago
the downside is that the go runtime doesn't expect memory reads to page fault, so you may end up with stalls/latency/under-utilization if part of your dataset is paged out (like if you have a large cdb file w/ random access patterns). Using file IO, the Go runtime could be running a different goroutine if there is a disk read, but with mmap that thread is descheduled but holding an m & p. I'm also not sure if there would be increased stop the world pauses, or if the async preemption stuff would "just work".

Section 3.2 of this paper has more details: https://db.cs.cmu.edu/papers/2022/cidr2022-p13-crotty.pdf

vlovich123•1h ago
To me this indicates a limitation of the API. Cause you do want to maintain that the kernel can page out that memory under pressure while userspace accesses that memory asynchronously while allowing the thread to do other asynchronous things. There’s no good programming model/OS api that can accomplish this today.
im3w1l•1h ago
There are apis that sort of let you do it: mincore, madvise, userfaultfd.
bcrl•12m ago
None of those APIs are cheap enough to call in a fast path.
avianlyric•1h ago
There is no sensible OS API that could support this, because fundamentally memory access is a hardware API. The OS isn’t involved in normal memory reads, because that would be ludicrously inefficient, effectively requiring a syscall for every memory operation, which effectively means a syscall for any operation involving data I.e. all operations.

Memory operations are always synchronous because they’re performed directly as a consequence of CPU instructions. Reading memory that’s been paged out results in the CPU itself detecting that the virtual address isn’t in RAM, and performing a hardware level interrupt. Literally abandoning a CPU instruction mid execution to start executing an entirely separate set of instructions which will hopefully sort out the page fault that just occurred, then kindly ask the CPU to go back and repeat the operation that caused the page fault.

OS is only involved only because it’s the thing that provided the handling instructions for the CPU to execute in the event of a page fault. But it’s not in anyway actually capable of changing how the CPU initially handles the page fault.

Also the current model does allow other threads to continue executing other work while the page fault is handled. The fault is completely localised to individual thread that triggered the fault. The CPU has no concept of the idea that multiple threads running on different physical core are in anyway related to each other. It also wouldn’t make sense to allow the interrupted thread to someone kick off a separate asynchronous operation, because where is it going to execute? The CPU core where the page fault happened is needed to handle the actual page fault, and copy in the needed memory. So even if you could kick off an async operation, there wouldn’t be any available CPU cycles to carry out the operation.

Fundamentally there aren’t any sensible ways to improve on this problem, because the problem only exists due to us pretending that our machines have vastly more memory than they actually do. Which comes with tradeoffs, such as having to pause the CPU and steal CPU time to maintain the illusion.

If people don’t like those tradeoffs, there’s a very simple solution. Put enough memory in your machine to keep your entire working set in memory all the time. Then page faults can never happen.

im3w1l•41m ago
I think you have a misunderstanding of how disk IO happens. The CPU core sends a command to the disk "I want some this and that data", then the CPU core can go do something else while the disk services that request. From what I read the disk actually puts the data directly into memory by using DMA, without needing to involve the CPU.

So far so good, but then the question is to ensure that the CPU core has something more productive to do then just check "did the data arrive yet?" over and over and coordinating that is where good apis come in.

dapperdrake•25m ago
(Not the person you are replying to.)

There is nothing in the sense of Python async or JS async that the OS thread or OS process in question could usefully do on the CPU until the memory is paged into physical RAM. DMA or no DMA.

The OS process scheduler can run another process or thread. But your program instance will have to wait. That’s the point. It doesn’t matter whether waiting is handled by a busy loop a.k.a. polling or by a second interrupt that wakes the OS thread up again.

That is why Linux calls it uninterruptible sleep.

EDIT: io_uring would of course change your thread from blocking syscalls to non-blocking syscalls. Page faults are not a syscall, as GP pointed out. They are, however, a context-switch to an OS interrupt handler. That is why you have an OS. It provides the software drivers for your CPU, MMU, and disks/storage. Here this is the interrupt handler for a page fault.

bcrl•12m ago
What everyone forgets is just how expensive context switches are on modern x86 CPUs. Those 512 bit vector registers fill up a lot of cache lines. That's why async tends to win over processes / threads for many workloads.
ori_b•25m ago
I think you have a misunderstanding of how the OS is signaled about disk I/O being necessary. Most of the post above was discussing that aspect of it, before the OS even sends the command to the disk.
lmz•7m ago
It's hard to say on one hand "I use mmap because I don't want fancy APis for every read" and on the other "I want to do something useful on page fault" because you don't want to make every memory read a possible interruption point.
kragen•15m ago
> There is no sensible OS API that could support this, because fundamentally memory access is a hardware API.

Not only is there a sensible OS API that could support this, Linux already implements it; it's the SIGSEGV signal. The default way to respond to a SIGSEGV is by exiting the process with an error, but Linux provides the signal handler with enough information to do something sensible with it. For example, it could map a page into the page frame that was requested, enqueue an asynchronous I/O to fill it, put the current green thread to sleep until the I/O completes, and context-switch to a different green thread.

Invoking a signal handler only has about the same inherent overhead as a system call. But then the signal handler needs another couple of system calls. So on Linux this is over a microsecond in all. That's probably acceptable, but it's slower than just calling pread() and having the kernel switch threads.

Some garbage-collected runtimes do use SIGSEGV handlers on Linux, but I don't know of anything using this technique for user-level virtual memory. It's not a very popular technique in part because, like inotify and epoll, it's nonportable; POSIX doesn't specify that the signal handler gets the arguments it would need, so running on other operating systems requires extra work.

im3w1l also mentions userfaultfd, which is a different nonportable Linux-only interface that can solve the same thing but is, I think, more efficient.

habibur•2h ago
Is mmap still faster than fread? That might have been true in the 90s but I was wondering about current improvements.

If you have enough free memory, the file will be cached in memory anyway instead of residing on disk. Therefore both will be reading from memory, albeit through different API.

Looking for recent benchmark or view from OS developers.

stingraycharles•2h ago
In our experience building a high performance database server: absolutely. If your line of thinking is “if you have enough free memory”, then these types of optimizations aren’t for you. one of the main benefits is eliminating an extra copy.

additionally, mmap is heavily optimized for random access, so if that’s what you’re doing, then you’ll have a much better time with it than fread.

(I hope a plug is not frowned upon here: if you like this kind of stuff, we’re a fully remote company and hiring C++ devs: https://apply.workable.com/quasar/j/436B0BEE43/ )

YouAreWRONGtoo•1h ago
If you can't post a salary, you shouldn't post a job opening.

(Not that you can afford me.)

Also, your company is breaking the law by false advertising. It suggests your current leadership is fucking stupid. Why do you work for a criminal enterprise?

vlovich123•1h ago
What’s the false advertising?
deaddodo•1h ago
Yeah, I took a look at the posting and it’s a bog standard job posting.

I assume they’re referring to the no-salary aspect and (based on their speech style) are in the US. But, even in that case, it would only matter if the posting were targeted to one of the states that require salary information and the company operated or had a presence in said state. Since it’s an EU company, that’s almost definitely not the case.

jasonwatkinspdx•48m ago
I'd be shocked if anyone would hire you after seeing this behavior...
do_not_redeem•2h ago
Even if the file is cached, fread has to do a memcpy. mmap doesn't.
gpderetta•1h ago
fread is (usually) buffered io, so it actually does two additional mem copies (kernel to FILE buffer then to user buffer)
buybackoff•1h ago
It looks suspicious at 25x. Even 2.5x would be suspicious unless reading very small records.

I assume both cases have the file cached in RAM already fully, with a tiny size of 100MB. But the file read based version actually copies the data into a given buffer, which involves cache misses to get data from RAM to L1 for copying. The mmap version just returns the slice and it's discarded immediately, the actual data is not touched at all. Each record is 2 cache lines and with random indices is not prefetched. For the CPU AMD Ryzen 7 9800X3D mentioned in the repo, just reading 100 bytes from RAM to L1 should take ~100 nanos.

The benchmark compares actually getting data vs getting data location. Single digit nanos is the scale of good hash tables lookups with data in CPU caches, not actual IO. For fairness, both should use/touch the data, eg copy it.

Scaevolus•1h ago
Yeah, 3.3ns is about 12 CPU cycles. You can indeed create a pointer to a memory location that fast!
kragen•26m ago
> For the CPU AMD Ryzen 7 9800X3D mentioned in the repo, just reading 100 bytes from RAM to L1 should take ~100 nanos.

I think this is the wrong order of magnitude. One core of my Ryzen 5 3500U seems to be able to run memcpy() at 10 gigabytes per second (0.1 nanoseconds per byte) and memset() at 31 gigabytes per second (0.03 nanoseconds per byte). I'd expect a sequential read of 100 bytes to take about 3 nanoseconds, not 100 nanoseconds.

However, I think random accesses do take close to 100 nanoseconds to transmit the starting row and column address and open the row. I haven't measured this on this hardware because I don't have a test I'm confident in.

bcrl•17m ago
100 nanoseconds from RAM is correct. Latency != bandwidth. 3 nanoseconds would be from cache or so on a Ryzen. You ain't gonna get the benefits of prefetching on the first 100 bytes.
kragen•12m ago
Yes, my comment clearly specified that I was talking about sequential reads, which do get the benefits of prefetching, and said, "I think random accesses do take close to 100 nanoseconds".
bcrl•2m ago
If you're doing large amounts of sequential reads from a filesystem, it's probably not in cache. You only get latency that low if you're doing nothing else that stresses the memory subsystem, which is rather unlikely. Real applications have overhead, which is why microbenchmarks like this are useless. Microbenchmarks are not the best first order estimate for programmers to think of.
a-dub•14m ago
doing these sorts of benchmarks is actually quite tricky. you must clear the page cache by allocating >1x physical ram before each attempt.

moreover, mmap by default will load lazy, where mmap with MAP_POPULATE will prefetch. in the former case, reporting average operation times is not valid because the access time distributions are not gaussian (they have a one time big hit at first touch). with MAP_POPULATE (linux only), there is long loading delay when mmap is first called, but then the average access times will be very low. when pages are released will be determined by the operating system page cache eviction policy.

the data structure on top is best chosen based on desired runtime characteristics. if it's all going in ram, go ahead and use a standard randomized hash table. if it's too big to fit in ram, designing a structure that is aware of lru style page eviction semantics may make sense (ie, a hash table or other layout that preserves locality for things that are expected to be accessed in a temporally local fashion.)

MayCXC•1h ago
wowie. mmap also dramatically improved perf for LLaMA: https://justine.lol/mmap/
mholt•1h ago
Just this month, I've learned the hard way that some file systems do not play well with mmap: https://github.com/mattn/go-sqlite3/issues/1355

In my case, it seems that Mac's ExFAT driver is incompatible with sqlite's WAL mode because the driver returned a memory address that is misaligned on ARM64. Most bizarre error I've encountered in years.

So, uh, mind your file systems, kids!

vlovich123•1h ago
I would be very careful about that conclusion. Reading that thread it sounds like you’re relying on Claude to make this conclusion but you haven’t actually verified what the address being returned actually is.

The reason I’m skeptical is three fold. The first is that it’s generally impossible for a filesystem to mmap return a pointer that’s not page boundary aligned. The second is that unaligned accesses are still fine on modern ARM is not a SIGBUS. The third is that Claude’s reasoning that the pointer must be 8-byte aligned and that indicates a misaligned read is flawed - how do you know that SQLite isn’t doing a 2-byte read at that address?

If you really think it’s a bad alignment it should be trivial to reproduce - mmap the file explicitly and print the address or modify the SQLite source to print the mmap location it gets.

mholt•1h ago
I'd love to be wrong, but the address it's referring to is the correct address from the error / stack trace.

I honestly don't know anything about this. There's no search results for my error. ChatGPT and Claude and Grok all agreed one way or another, with various prompts.

Would be happy to have some help verifying any of this. I just know that disabling WAL mode, and not using Mac's ExFAT driver, both fixed the error reliably.

commandersaki•1h ago
This is a good article but I'm wondering what is the relationship between this website/company and varnish-cache.org, since in the article they make claims of releasing Varnish Cache, and the article wasn't written by Poul-Henning Kamp.
Ingon•1h ago
When I adopted mmap in klevdb [1], I saw a dramatic performance improvements. So, even as klevdb completes a write segment, it will reopen, on demand, the segment for reading with mmap (segments are basically part of write only log). With this any random reads are super fast (but of course not as fast as sequential ones).

[1] https://github.com/klev-dev/klevdb

gustavpaul•1h ago
The MmapReader is not copying the requested byte range into the buf argument, so if ever the underlying file descriptor is closed (or the file truncated out of band) any subsequent slice access will throw SIGBUS, which is really unpleasant.

It also means the latency due to pagefaults is shifted from inside mmapReader.ReadRecord() (where it would be expected) to wherever in the application the bytes are first accessed, leading to spooky unpreditactable latency spikes in what are otherwise pure functions. That inevitably leads to wild arguments about how bad GC stalls are :-)

An apples to apples comparison should be copying the bytes from the mmap buffer and returning the resulting slice.

dapperdrake•19m ago
It’s not accessible until it is in user space. (Virtual memory addresses mapped to physical RAM holding the data.)

Good point.

liuliu•1h ago
mmap is a good crutch when you 1. don't have busy polling / async IO API available and want to do some quick & dirty preloading tricks; 2. don't want to manage the complexity of in-memory cache, especially cross-processes ones.

Obviously if you have kernel-backed async IO APIs (io_uring) and willing to dig into the deeper end (for better managed cache), you can get better performance than mmap. But in many cases, mmap is "good-enough".

kragen•31m ago
The simple answer to "How do memory maps (mmap) deliver faster file access?" is "sometimes", but the blog post does give some more details.

I was suspicious of the 25× speedup claim, but it's a lot more plausible than I thought.

On this Ryzen 5 3500U running mostly at 3.667GHz (poorly controlled), reading data from an already-memory-mapped page is as fast as memcpy (about 10 gigabytes per second when not cached on one core of my laptop, which works out to 0.1 nanoseconds per byte, plus about 20 nanoseconds of overhead) while lseek+read is two system calls (590ns each) plus copying bytes into userspace (26–30ps per byte for small calls, 120ps per byte for a few megabytes). Small memcpy (from, as it happens, an mmapped page) also costs about 25ps per byte, plus about 2800ps per loop iteration, probably much of which is incrementing the loop counter and passing arguments to the memcpy function (GCC is emitting an actual call to memcpy, via the PLT).

So mmap will always be faster than lseek+read on this machine, at least if it doesn't have a page fault, but the point at which memcpy from mmap would be 25× faster than lseek+read would be where 2×590 + .028n = 25×(2.8 + .025n) = 70 + .625n. Which is to say 1110 = .597n ∴ n = 1110/.597 = 1859 bytes. At that point, memcpy from mmap should be 49ns and lseek+read should be 1232ns, which is 25× as big. You can cut that size more than in half if you use pread() instead of lseek+read, and presumably io_uring would cut it even more. If we assume that we're also taking cache misses to bring in the data from main memory in both cases, we have 2×590 + .1n = 25×(2.8 + .1n) = 70 + 2.5n, so 1110 = 2.4n ∴ n = 1110/2.4 = 462 bytes.

On the other hand, mmap will be slow if it's hitting a page fault, which sort of corresponds to the case where you could have cached the result of lseek+read in private RAM, which you could do on a smaller-than-pagesize granularity, which potentially means you could hit the slow path much less often for a given working set. And lseek+read has several possible ways to do make the I/O asynchronous, while the only way to make mmap page faults asynchronous is to hit the page faults in different threads, which is a pretty heavyweight mechanism.

On the other hand, lseek+read with a software cache is sort of using twice as much memory (one copy is in the kernel's buffer cache and another copy is in the application's software cache) so mmap could still win. And, if there are other processes writing to the data being queried, you need some way to invalidate the software cache, which can be expensive.

(On the gripping hand, if you're reading from shared memory while other processes are updating it, you're probably going to need some kind of locking or lock-free synchronization with those other processes.)

So I think a reasonably architected lseek+read (or pread) approach to the problem might be a little faster or a little slower than the mmap approach, but the gap definitely won't be 25×. But very simple applications or libraries, or libraries where many processes might be simultaneously accessing the same data, could indeed get 25× or even 256× performance improvements by letting the kernel manage the cache instead of trying to do it themselves.

Someone at a large user of Varnish told me they've mostly removed mmap from their Varnish fork for performance.