Category Archives: Linux

The Core of Microprocessors

Most modern computers today operate with multiple processors and the processor in-turn have multiple cores. Below is a breakdown of the architecture of a modern computer / processor. I took these notes so that it’s easy for me to understand and I hope it helps others.

Motherboards have  sockets that can fit Microprocessors  ( usually 2 )

Each Microprocessor has multiple computing components, which are actual independent central processing units also known as “Cores” ( usually 6 per socket ) . These cores share some computing functions like floating point calculations, while performing integer calculations independently.

Intel introduced the concept of Hyper-Threading. For each processor core that is physically present, the operating system addresses two virtual or logical cores, and shares the workload between them when possible.  ( usually there are 2 Hyper-Threads per core ).

When you issue the command like “procinfo” to list the number of CPU’s in a server (Linux/Unix ) . The number of CPU might be misleading as the command identifies each Hyper-Thread as a core. Hence A server with 2 sockets and 6 core processor in each socket will be reported to have 24 CPU’s. This is correct from OS perspective as OS treats each Hyper-Thread as a CPU.

Depending on the hardware architecture there can be multiple levels of caches based. The block diagram below describes the association of cache/memory  to processing units in a server.




Leave a comment

Filed under Hardware, JVM, Linux

Hugepages and Java

As a data point, at a previous employer we played a little with the use of HugePages and memory mapped files in an attempt to get better performance.
Java’s support for the use of HugePages is on a best effort basis and our experimentation found that java was initially using the HugePages, but over time (a few hours), the HugePages were no longer used by the JVM—thus effectively reducing the available amount of RAM by the amount allocated for HugePages. We ended up disabling HugePages for our usage. I do not recall any concern/investigation about the Anonymous huge pages.
In the above case, however, we were constantly changing the memmapped files (these were large image files), since each request would access different image files, and the files were accessed over network storage.

Leave a comment

Filed under JVM, Linux

Performance impact of dirty pages in Linux

Memory (RAM) is divided into pages of equal size. A page is the smallest unit of memory that can be manipulated.

My Tech Project Notes describes Dirty Pages as

Dirty pages are the pages in memory (page cache) that have been updated and therefore have changed from what is currently stored on disk. This usually happens when an existing file on the disk is modified or appended.

Page cache on a Linux system is the area where filesystem based I/O is cached and that these settings affect how the cache is utilized by the kernel.

We can tune pdflush to determine how much RAM based cache to use for (dirty pages) data targeted to disk and how frequently to flush that cached data by writing the pages back to disk.

There are two types of flush to disk in Linux and parameters / ratios controlling how often they are triggered

1. Stop the world – Controlled by dirty_ratio.

This is the Big ass flush, that will lock the memory during the flush, the ditry_ratio determines the threshold based on the total size of the Memory/Dirty page Cache  ( Dirty page cache size is not the same as total RAM size, its usually less than total RAM size)

For example, if the dirty_ratio is set to 20%, or 0.2, a “stop the world” flush is invoked when the dirty page cache is  20% full.

2. Background Flush – controlled by dirty_background_ratio

This is a intrusive flush, similar to CMS in JVM, which happens in parallel and does not block the memory for reads and writes.

The default value for dirty_background_ratio is 50% of dirty_ratio, or any value lower than 50%  of the dirty_ratio set by the admin.

for example, if you set the dirty_page ratio to be 20% and the dirty_background_ratio to be 20% as well, then the kernel will set the dirty_background_ratio to 10%.

the logic in the kernel would look something similar to this.

If ( dirty_background_ratio >= dirty_ratio )


dirty_background_ratio = dirty_ratio / 2


Leave a comment

Filed under Linux