简体   繁体   中英

In linux (x86 system), does multiple instances of same elf file benefit from cache?

In linux (x86 system), does multiple instances of same elf file benefit from cache? I mean TLB-i , L1-i , etc.

If I interpret your question correctly, you mean to say that when multiple processes are loaded from the same executable, then the code is shared between the processes in physical memory. These multiple 'instances' have the following benefits (rather than just making two copies in physical memory) -

  1. Usage of physical memory is reduced, making space for other uses.

  2. There are two types of caches - one for physical memory and other for page tables. The first are the L1, L2, L3, and on some systems L4 caches. They have different positions in the CPU topology in the system, but serve the same purpose - store some part of RAM locally, near the processor(s). When code is shared amongst multiple processes, the usage of RAM is more localized (due to all of code being at one location), and thus cache thrashing reduces.

  3. The page-table cache or TLB (translation look-aside buffer, or something like that) is flushed on every switch between processes, and thus they are not benefited from code-sharing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM