Tag: cache

Uncategorized

cache hacks

https://dmalcolm.fedorapeople.org/gcc/2015-08-31/rst-experiment/how-to-use-inline-assembly-language-in-c-code.html#clobbers

compiler explorer:
https://godbolt.org/z/kANkNL

void maccess(void *p) { asm volatile("movq (%0), %%rax\n" : : "c"(p) : "rax"); }

moves quadword from mem adress into rax register
AT&T syntax?

shm_open and mmap:

quote: mmap works in multiples of the page size on your system. If you're doing this on i386/amd64 or actually most modern CPUs, this will be 4096.

In the man page of mmap on my system it says: "offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).". On some systems for historical reasons the length argument may be not a multiple of page size, but mmap will round up to a full page in that case anyway.

ethicalh

cache replacement policies

MIN

  • Replace the cache entry that will not be used for the
    longest time into the future
  • Optimality proof based on exchange: if evict an entry
    used sooner, that will trigger an earlier cache miss

Least Recently Used (LRU)

  • Replace the cache entry that has not been used for
    the longest time in the past
  • Approximation of MIN

Least Frequently Used (LFU)

  • Replace the cache entry used the least often (in the
    recent past)