Hacker News new | ask | show | jobs
by jeffbee 29 days ago
It's unfortunately a hard message to sell, but your program itself should never be backed by a file, for this exact reason. All code should be remapped into anonymous memory that is 1) right where you want it; 2) backed by hugepages; and 3) not shared. You are gaining nothing by trying to share objects with other processes, and you are losing a great deal of performance. The tradeoff made a little sense in the 1980s when they came up with it but in this century it simply doesn't.
1 comments

If the code is mapped readable and not mutated how does it make a difference?

The code will be prefetched in to local (executing) CPU cache just the same. No invalidations will take place across NUMA zones.

Modern DLLs on e.g. Linux use PIC and not mutable relocations.