Re:On building portable Linux binaries
by hamburglar on Saturday September 27, 2014 @06:22PM
(#8378376)
> I'm not sure which heuristics you're referring to.
As I said, the details are somewhat hazy for me, but my understanding is that KSM maintains a notion of how recently and how frequently a page changes, in order to determine whether it's a good candidate for deduplication or whether that would just be a waste of time that causes unnecessary page faults. I could be completely wrong on this, but I don't think it's quite as simple as "if two pages are identical, KSM de-duplicates them."
Why would it need those insights? If two pages are identical, KSM de-duplicates them. The linker-assisted method would do the same, only earlier.
< [...] it must apply heuristics to predict whether a page is going to get written to, whereas the dynamic linker knows exactly which sections of dynamic libs can be shared.
I'm not sure which heuristics you're referring to. I think KSM de-duplicates the pages and sets the single remaining copy as copy-on-write, to detect writes (I wouldn't call this a heuristic). Both KSM and the dynamic linker would only be able to de-duplicate entire pages, since that's what the granularity the OS provides for sharing memory between processes.
> Not to mention that KSM works less efficiently by recognizing duplicate pages after the fact and merging them, rather than skipping the duplication in the first place.
OK, fair enough.