News for hackers. Stuff that matters.
Re:Memory is slow, Disk is fast – Part 2 by jared_hulbert on Thursday September 04, 2025 @09:46PM (#45134258)
YES! gcc and clang don't like to optimize this. But they do if you hardcode the size_bytes to an aligned value. It kind of makes sense, what if a user passes size_bytes as 3? With enough effort the compilers could handle this, but it's a lot to ask.

I just ran MAP_POPULATE the results are interesting.

It speeds up the counting loop. Same speed or higher as the my read() to a malloced buffer tests.

HOWEVER... It takes a longer time overall to do the population of the buffer. The end result is it's 2.5 seconds slower to run the full test when compared to the original. I did not guess that one correctly.

time ./count_10_unrolled ./mnt/datafile.bin 53687091200 unrolled loop found 167802249 10s processed at 5.39 GB/s ./count_10_unrolled ./mnt/datafile.bin 53687091200 5.58s user 6.39s system 99% cpu 11.972 total time ./count_10_populate ./mnt/datafile.bin 53687091200 unrolled loop found 167802249 10s processed at 8.99 GB/s ./count_10_populate ./mnt/datafile.bin 53687091200 5.56s user 8.99s system 99% cpu 14.551 total

Re:Memory is slow, Disk is fast – Part 2 by mischief6 on Thursday September 04, 2025 @10:28PM (#45134454)
it could be interesting to see what ispc does with similar code.
Re:Memory is slow, Disk is fast – Part 2 by titanomachy on Friday September 05, 2025 @01:18AM (#45135200)
Hmm, I expected some slowdown from POPULATE, but I thought it would still come out ahead. Interesting!