Better HN
topnewbestaskshowjobs
Log inSign up

rageoholic

2 karma · joined Aug 2, 2021 (5y ago) · 2 submissions

Submissions

comment 4y ago · link · parent

There's also stuff you can optimize like cache efficiency. Sometimes you can do more work on an array than a linked list but the array is faster because linked lists miss cache pretty consistently.

comment 5y ago · link · parent

Linux actually will let you allocate address space without allocating pages. You just disable all access and the OS knows that it doesn't actually need to give you any pages. You then commit by using mprotect to enable access to the page. There are madvise hints you can use to tell the OS that you no longer care about what's in the page, although they're a bit misnamed for compatibility reasons(MADV_DONTNEED will immediately free the pages while MADV_FREE will lazily free the pages)

Edit: Actually it looks like the behavior might have changed. hmmm. I guess read the man pages tied to the kernel you're using

Edit 2: Nope, I misread the most recent manpage. I should not read manpages when I'm tired. It does zero fill specifically for anonymous mappings