News for hackers. Stuff that matters.
Re:Computers are fast by exDM69 on Tuesday May 13, 2014 @10:31AM (#7738294)
Ah, thanks!

Using MAP_POPULATE, I'm seeing this go from 104,276 page faults down to 130 page faults. However, I'm only seeing a modest increase in overall performance, goes from 160 ms to 130 ms for my ~500 MB test file. MAP_POPULATE + MAP_NONBLOCK is as bad as not using MAP_POPULATE (same number of page faults).

Could the number of TLB misses from using huge pages be a major factor too? Page faults alone do not explain the huge perf difference. (edit: perf stat tells me I'm only missing 0.19% of TLB lookups and only 3% dcache misses)

I also tried with a 4 GB file and I see two interesting effects. First of all, using MAP_POPULATE is slower, which I presume is because physical memory is exhausted (6 G memory total). Secondly, I see less than 100k page faults which suggests that bigger pages (2M or 1G?) are being used (10x bigger file, a little less page faults).

Re:Computers are fast by dchichkov on Tuesday May 13, 2014 @11:33AM (#7738621)
How about the following?

    HUGETLB_MORECORE=yes LD_PRELOAD=libhugetlbfs.so
Re:Computers are fast by nkurz on Tuesday May 13, 2014 @03:13PM (#7740029)
This is well worth trying, but not directly applicable to reading from a file. This would help if you were allocating a buffer with malloc() and you wanted it to be backed by hugepages. But if you have control of the source, you are probably better using MAP_HUGETLB with madvise() or mmap(), or using the get_huge_pages() directly instead of using the LD_PRELOAD.