<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ayush Bajpai</title>
    <description>The latest articles on DEV Community by Ayush Bajpai (@mrayushbajpai).</description>
    <link>https://dev.to/mrayushbajpai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1284616%2Fb58e57f7-19af-433d-9985-8fbd85bc4ae7.png</url>
      <title>DEV Community: Ayush Bajpai</title>
      <link>https://dev.to/mrayushbajpai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrayushbajpai"/>
    <language>en</language>
    <item>
      <title>"MMAP" System Call for DBMS</title>
      <dc:creator>Ayush Bajpai</dc:creator>
      <pubDate>Sun, 13 Apr 2025 07:49:10 +0000</pubDate>
      <link>https://dev.to/mrayushbajpai/mmap-system-call-for-dbms-2c5k</link>
      <guid>https://dev.to/mrayushbajpai/mmap-system-call-for-dbms-2c5k</guid>
      <description>&lt;p&gt;&lt;strong&gt;MMAP&lt;/strong&gt;, which stands for &lt;strong&gt;Memory Mapping&lt;/strong&gt;, allows to map files into a process's virtual memory space. It makes it faster to load certain things, as the common data can be kept in primary memory (like RAM), which is significantly faster than, say HDD or SSD.  &lt;/p&gt;

&lt;p&gt;It is typically achieved using the &lt;code&gt;mmap()&lt;/code&gt; system call provided by most modern operating systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  How MMAP Works?
&lt;/h2&gt;

&lt;p&gt;When a file is &lt;strong&gt;memory mapped&lt;/strong&gt;, the operating system gets a say as to what it wants to load in the memory, and what it wants to keep in the disk.  &lt;/p&gt;

&lt;p&gt;The Operating System does not load the entire file into memory immediately, and instead it's associated with a range of virtual memory addresses.  &lt;/p&gt;

&lt;p&gt;As the program reads or writes to a file which is memory mapped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the page is already loaded in memory - Success ✅

&lt;/li&gt;
&lt;li&gt;If not, then a &lt;strong&gt;Page Fault&lt;/strong&gt; occurs, and the control is transferred to the &lt;strong&gt;OS page fault handler&lt;/strong&gt; as:


&lt;ol&gt;
&lt;li&gt;The OS determines which file and offset correspond to the faulting address.&lt;/li&gt;
&lt;li&gt;It allocates a physical memory page (from RAM)&lt;/li&gt;
&lt;li&gt;It reads the corresponding file block from disk into RAM&lt;/li&gt;
&lt;li&gt;Updates the page table to map the virtual page to the newly loaded physical page.&lt;/li&gt;
&lt;li&gt;Marks it &lt;strong&gt;read-only&lt;/strong&gt; or &lt;strong&gt;writable&lt;/strong&gt; based on the &lt;code&gt;PROT_*&lt;/code&gt; flags.
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It should, however be noted that memory might have &lt;strong&gt;Dirty Pages&lt;/strong&gt;, i.e. pages that already have some changes in them in primary memory, which are not yet updated to the disk. If the OS needs to overwrite any such page, it also would require a &lt;strong&gt;flush policy&lt;/strong&gt; to handle how the data will be flushed back to the disk, before overwriting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7w0y04k26ethja8aafax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7w0y04k26ethja8aafax.png" alt="MMAP Diagram" width="728" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  C Example for mmap
&lt;/h2&gt;

&lt;p&gt;Here's a C Example with detailed comments, that demonstrates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Opening a file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mapping it into memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reading from the mapped memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing to it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flushing changes to disk using &lt;code&gt;msync()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unmapping and closing the file&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;fcntl.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;      // For open()&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;sys/mman.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;   // For mmap()&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;sys/stat.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;   // For fstat()&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;     // For close(), lseek(), write()&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;     // For memcpy()&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="cp"&gt;#define FILENAME "example_mmap.txt"
#define FILESIZE 4096  // 4KB
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;stat&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 1: Open (or create) the file&lt;/span&gt;
    &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FILENAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;O_RDWR&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;O_CREAT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mo"&gt;0666&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;perror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"open"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 2: Ensure file is at least FILESIZE long&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ftruncate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FILESIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;perror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ftruncate"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 3: Memory-map the file&lt;/span&gt;
    &lt;span class="n"&gt;mapped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FILESIZE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PROT_READ&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;PROT_WRITE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAP_SHARED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mapped&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;MAP_FAILED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;perror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mmap"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"File successfully memory-mapped.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 4: Read the first few bytes (may be zero if file is empty)&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Initial contents: &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;%.32s&lt;/span&gt;&lt;span class="se"&gt;\"\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 5: Write something to the mapped region&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello via mmap!&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strlen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// Equivalent to writing into memory&lt;/span&gt;

    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Modified contents in memory: &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;%.32s&lt;/span&gt;&lt;span class="se"&gt;\"\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 6: Flush changes to disk&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FILESIZE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MS_SYNC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;perror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"msync"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Changes successfully flushed to disk.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Step 7: Unmap memory and close the file&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;munmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mapped&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FILESIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;perror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"munmap"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"File unmapped and closed.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;EXIT_SUCCESS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Use MMAP in a DBMS
&lt;/h2&gt;

&lt;p&gt;MMAP is particularly beneficial when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Workload is read-heavy.

&lt;/li&gt;
&lt;li&gt;System memory is sufficient to cache working set.

&lt;/li&gt;
&lt;li&gt;Simplicity and low-overhead are priorities.

&lt;/li&gt;
&lt;li&gt;You trust the OS’s page replacement and sync mechanisms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It might be &lt;strong&gt;suboptimal&lt;/strong&gt; for write-heavy, large-scale distributed DBMS systems like PostgreSQL or MySQL, which prefer explicit control over I/O and caching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and Caveats
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Less Control:
&lt;/h4&gt;

&lt;p&gt;MMAP delegates caching and eviction to the OS, which might not be optimal for DBMS-specific patterns.  &lt;/p&gt;

&lt;h4&gt;
  
  
  I/O Patterns:
&lt;/h4&gt;

&lt;p&gt;Random writes can generate frequent page faults and dirty pages, leading to thrashing.   &lt;/p&gt;

&lt;h4&gt;
  
  
  Consistency and Sync:
&lt;/h4&gt;

&lt;p&gt;You must use msync() or mprotect() carefully to ensure consistency and durability (especially for WAL-based systems).   &lt;/p&gt;

&lt;h4&gt;
  
  
  Portability:
&lt;/h4&gt;

&lt;p&gt;Some platforms or file systems (e.g., networked FS) behave unpredictably with MMAP.   &lt;/p&gt;

&lt;h4&gt;
  
  
  Address Space Limits:
&lt;/h4&gt;

&lt;p&gt;On 32-bit systems, you’re constrained by virtual address space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance Considerations of Using mmap() in DBMS
&lt;/h2&gt;

&lt;p&gt;While mmap() can simplify file I/O and offer performance benefits in some cases, it's important to understand the performance trade-offs it introduces when used in database systems:&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Potential Advantages:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Copy I/O:&lt;/strong&gt; Since mmap() maps a file directly into the process's address space, the kernel can avoid explicit copies between user and kernel space, improving I/O efficiency.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;On-Demand Paging:&lt;/strong&gt; The operating system loads only the necessary pages into memory, which can save memory if the entire file isn't accessed. &lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Page Caching:&lt;/strong&gt; OS-level page caching can result in fast access times for frequently read data, without the database developer needing to implement a custom caching layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⚠️ Potential Pitfalls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Page Fault Overhead:&lt;/strong&gt; Every access to a not-yet-loaded page triggers a page fault, which involves a context switch and can be expensive if not handled efficiently.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Less Control Over I/O Scheduling:&lt;/strong&gt; Unlike pread()/pwrite() or custom read-ahead strategies, mmap() offloads much of the paging and flushing behavior to the kernel. This can lead to unpredictable latencies, especially under memory pressure.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Writeback Latency:&lt;/strong&gt; Dirty pages in memory must be flushed to disk. If the OS's flushing (e.g., via msync() or madvise()) is not carefully managed, write operations can block for long periods, introducing latency spikes.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Interaction with Virtual Memory Limits:&lt;/strong&gt; On 32-bit systems or environments with limited address space, mapping large files can exhaust virtual memory quickly, causing issues even if physical RAM is available.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Example Case
&lt;/h3&gt;

&lt;p&gt;Imagine a DBMS using mmap() to load a 10 GB file. If the system has only 8 GB of RAM and the working set is 7 GB, things may run smoothly. But if access patterns become random or the working set exceeds available memory, the OS might start swapping or aggressively evicting pages, leading to thrashing and degraded performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Example: LMDB
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;LMDB uses MMAP exclusively.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;All DB operations happen via direct memory access.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;No buffer pool, no write-ahead logging — the filesystem and MMAP handle durability.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Pages are copy-on-write to preserve snapshot isolation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;MMAP&lt;/strong&gt; in &lt;strong&gt;DBMS&lt;/strong&gt; is a technique where database files are &lt;strong&gt;accessed via memory&lt;/strong&gt; instead of manual file I/O. It simplifies the design by letting the &lt;strong&gt;OS manage disk-to-memory translation&lt;/strong&gt; but comes with trade-offs in control, predictability, and scalability. It's ideal for embedded or read-optimized systems, less so for complex transactional engines needing fine-grained I/O control.&lt;/p&gt;

</description>
      <category>dbms</category>
      <category>database</category>
      <category>syscall</category>
      <category>mmap</category>
    </item>
    <item>
      <title>Data Models in DBMS</title>
      <dc:creator>Ayush Bajpai</dc:creator>
      <pubDate>Sun, 13 Apr 2025 06:18:23 +0000</pubDate>
      <link>https://dev.to/mrayushbajpai/data-models-in-dbms-34b0</link>
      <guid>https://dev.to/mrayushbajpai/data-models-in-dbms-34b0</guid>
      <description>&lt;p&gt;Database Management System allows us to store tons of data in an efficient manner. A &lt;strong&gt;Data Model&lt;/strong&gt; defines how data is stored, connected and accessed. Essentially, it is the backbone of DBMS.&lt;/p&gt;

&lt;p&gt;Here are some common Data Models Explained, and how they store data:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Hierarchical Data Model
&lt;/h3&gt;

&lt;p&gt;A hierarchical database model organizes data in a &lt;strong&gt;tree-like structure&lt;/strong&gt;. Data is stored in &lt;strong&gt;records&lt;/strong&gt;, each made up of one or more &lt;strong&gt;fields&lt;/strong&gt;, and each field holds a single value. The type of a record is defined by the combination of its fields. One special type of field is a &lt;strong&gt;link&lt;/strong&gt;, which connects a record to other related records. These links create parent-child relationships between records, forming a tree structure where each record can link to multiple child records, but only one parent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0xv3346p1gtysjq6rbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0xv3346p1gtysjq6rbe.png" alt="Hierarchical Data Model" width="800" height="405"&gt;&lt;/a&gt; Ex:- XML, Windows Registry&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Network Data Model
&lt;/h3&gt;

&lt;p&gt;Here, in contrast to the Hierarchical Data Model, the network model allows each record to have &lt;strong&gt;multiple parents&lt;/strong&gt; and &lt;strong&gt;multiple children&lt;/strong&gt;, forming a more flexible &lt;strong&gt;graph-like structure&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;This applies on two levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At the schema level, record types are connected through relationship types, forming a graph of how data can be related.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;At the data level, actual records (called record occurrences) are connected by relationships, also forming a graph&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fianficyel3umy5g0g9iz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fianficyel3umy5g0g9iz.png" alt="Network Data Model" width="800" height="448"&gt;&lt;/a&gt; Ex:- Integrated Data Store (IDS)&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Relational Data Model
&lt;/h3&gt;

&lt;p&gt;In the relational data model, data is organized into &lt;strong&gt;tables&lt;/strong&gt;, also known as &lt;strong&gt;relations&lt;/strong&gt;. Each table consists of &lt;strong&gt;rows (called tuples)&lt;/strong&gt; and &lt;strong&gt;columns (called attributes)&lt;/strong&gt;. Every row represents a single record, and each column represents a field containing a specific type of data.   &lt;/p&gt;

&lt;p&gt;Relationships between data are established through keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;primary key&lt;/strong&gt; uniquely identifies each row in a table.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;foreign key&lt;/strong&gt; creates a link between rows in different tables by referencing the primary key of another table.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike the hierarchical or network models, the relational model does not rely on explicit pointers or predefined paths between records. Instead, relationships are inferred through matching key values, providing flexibility and ease of querying using structured query language (SQL).   &lt;/p&gt;

&lt;p&gt;At both the schema level (structure of tables and keys) and the data level (actual rows and values), the relational model forms a logical structure rather than a physical graph or tree. This abstraction makes it easier to understand, maintain, and query complex data sets without dealing with how data is physically linked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxy2tv27lmtdejbf4fm9r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxy2tv27lmtdejbf4fm9r.jpg" alt="Relational Data Model" width="800" height="563"&gt;&lt;/a&gt; Ex:- MySQL, PostgreSQL&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Object Oriented Data Model
&lt;/h3&gt;

&lt;p&gt;In the object-oriented data model, data is represented as objects, similar to how it's handled in object-oriented programming languages. Each object contains both data (attributes) and behavior (methods), encapsulated into a single unit.&lt;/p&gt;

&lt;p&gt;Objects are grouped into classes, which define the structure (attributes) and behavior (methods) shared by all objects of that type. The model supports key object-oriented features such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inheritance&lt;/strong&gt; – Classes can inherit attributes and methods from other classes, promoting code reuse and hierarchy.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Encapsulation&lt;/strong&gt; – Data and behavior are bundled together, protecting internal states and exposing only what is necessary.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Polymorphism&lt;/strong&gt; – Objects can be accessed through references of their parent class type, allowing flexibility in method usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the &lt;strong&gt;schema level&lt;/strong&gt;, the structure of the database is defined through &lt;strong&gt;class hierarchies&lt;/strong&gt; and &lt;strong&gt;object relationships&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;At the &lt;strong&gt;data level&lt;/strong&gt;, actual &lt;strong&gt;object instances&lt;/strong&gt; are stored, each maintaining its state and behavior.&lt;/p&gt;

&lt;p&gt;Relationships between objects can be expressed through &lt;strong&gt;object references&lt;/strong&gt;, allowing complex structures like trees, graphs, and networks. The object-oriented model is especially suited for applications with complex data and behavior, such as CAD systems, multimedia databases, and object-oriented programming integrations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsyzbn95jcbg8ds1huni.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsyzbn95jcbg8ds1huni.webp" alt="Object Oriented Data Model" width="800" height="738"&gt;&lt;/a&gt; Ex:- db4o, ObjectDB&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Document Data Model (used in NoSQL)
&lt;/h3&gt;

&lt;p&gt;In the document data model, data is stored in the form of &lt;strong&gt;documents&lt;/strong&gt;, typically using formats like &lt;strong&gt;JSON, BSON, or XML&lt;/strong&gt;. Each document is a self-contained unit that holds all the data for a single object or entity, including nested structures and arrays.  &lt;/p&gt;

&lt;p&gt;Documents are grouped into &lt;strong&gt;collections&lt;/strong&gt; (similar to tables in the relational model), but unlike rows in a table, documents in a collection do not need to follow a fixed schema—each can have a different structure. This model provides flexibility and is well-suited for handling semi-structured or hierarchical data.  &lt;/p&gt;

&lt;p&gt;Key features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schema flexibility&lt;/strong&gt; – Documents can evolve over time without requiring changes to a rigid schema.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embedded data&lt;/strong&gt; – Related data can be stored within the same document (e.g., an order and its line items), reducing the need for joins.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rich queries&lt;/strong&gt; – Document databases support powerful query languages to filter, project, and manipulate nested fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgte7fhxoykxwjbym52i9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgte7fhxoykxwjbym52i9.jpg" alt="Document Data Model" width="622" height="360"&gt;&lt;/a&gt; Ex:- MongoDB, CouchDB&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Key-Value Data Model (NoSQL)
&lt;/h3&gt;

&lt;p&gt;The key-value data model is one of the simplest types of NoSQL database models. In this model, data is stored as a &lt;strong&gt;collection&lt;/strong&gt; of &lt;strong&gt;key-value pairs&lt;/strong&gt;, where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;key&lt;/strong&gt; is a &lt;strong&gt;unique identifier&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;The value is the associated data, which can be a &lt;strong&gt;string, number, binary blob, JSON, or any arbitrary data.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;This model is often compared to a &lt;strong&gt;hash table&lt;/strong&gt; or &lt;strong&gt;dictionary&lt;/strong&gt;, where you retrieve data by providing its key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key-value databases are best suited for scenarios like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Caching (e.g., Redis, Memcached)
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Session management
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;User preferences and profile storage
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Real-time data and large-scale applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9c7d0nezbqzib3eaycwe.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9c7d0nezbqzib3eaycwe.webp" alt="Key - Value Data Model" width="800" height="544"&gt;&lt;/a&gt; Ex:- Redis, DynamoDB&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Column-Family Data Model (NoSQL)
&lt;/h3&gt;

&lt;p&gt;The column-family data model is a NoSQL model that stores data in &lt;strong&gt;columns rather than rows&lt;/strong&gt;, making it especially suitable for &lt;strong&gt;large-scale, distributed systems&lt;/strong&gt; that require &lt;strong&gt;fast read/write access&lt;/strong&gt; across &lt;strong&gt;wide datasets&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this model, data is organized into structures called &lt;strong&gt;column families&lt;/strong&gt;, which are collections of related rows. Each row is identified by a &lt;strong&gt;row key&lt;/strong&gt;, and contains multiple columns, grouped logically into column families.&lt;/p&gt;

&lt;p&gt;Unlike the relational model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Columns are not fixed across all rows—each row can have a different set of columns.
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Columns can be grouped together for efficient storage and retrieval.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Graph Data Model
&lt;/h3&gt;

&lt;p&gt;The graph data model represents data as a &lt;strong&gt;network of nodes and edges&lt;/strong&gt;, making it ideal for capturing &lt;strong&gt;complex, interconnected relationships&lt;/strong&gt;.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nodes&lt;/strong&gt; represent entities (such as people, products, or locations).
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Edges&lt;/strong&gt; represent relationships between those entities (such as "friends with", "purchased", or "located in").
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Both nodes and edges can have &lt;strong&gt;properties—key-value pairs&lt;/strong&gt; that store relevant information. This structure allows relationships to be &lt;strong&gt;first-class citizens&lt;/strong&gt;, meaning they can be directly queried, navigated, and analyzed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nnd29a01v5bbvjg0iko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nnd29a01v5bbvjg0iko.png" alt="Image description" width="492" height="333"&gt;&lt;/a&gt; Ex:- Neo4j, Amazon Neptune&lt;/p&gt;

</description>
      <category>database</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Optimizing Windows...</title>
      <dc:creator>Ayush Bajpai</dc:creator>
      <pubDate>Thu, 10 Apr 2025 08:11:18 +0000</pubDate>
      <link>https://dev.to/mrayushbajpai/optimizing-windows-jpb</link>
      <guid>https://dev.to/mrayushbajpai/optimizing-windows-jpb</guid>
      <description>&lt;h2&gt;
  
  
  Complete Windows Optimization Guide
&lt;/h2&gt;

&lt;p&gt;Windows, by itself, isn't a particularly optimized operating system. With its multitude of features, many of which are designed to generate revenue, it's difficult to achieve optimal performance straight out of the box. In contrast to Linux, which prioritizes overall performance and efficiency, we'll need to make some modifications to Windows to fully harness the potential of our machines.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Oh and yeah..... if you can, consider switching to linux :)&lt;/em&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  Picking Up The Right ISO
&lt;/h3&gt;

&lt;p&gt;Now, while not necessary this guide will be starting from reinstalling Windows 11. The first step is to pick the right ISO. Now some people will tell you that you should use a pre-modified ISO: which are just Windows 11 ISO's but modified by others to remove the bloatware and useless things. &lt;/p&gt;

&lt;p&gt;I wouldn't recommend something like this, since it's really hard to tell whether an ISO is secure or not for the most. So, my recommendation: Get the Official Microsoft Windows 11 ISO. We'll just make the changes after installing Windows itself.&lt;/p&gt;

&lt;p&gt;So, head over to: &lt;a href="https://www.microsoft.com/en-us/software-download/windows11" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-us/software-download/windows11&lt;/a&gt; to grab the latest Windows 11 ISO.&lt;/p&gt;



&lt;h3&gt;
  
  
  Windows Installation
&lt;/h3&gt;

&lt;p&gt;For installing Windows 11, You will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows 11 ISO Image&lt;/li&gt;
&lt;li&gt;Rufus (for creating a bootable pen drive): &lt;a href="https://rufus.ie/en/" rel="noopener noreferrer"&gt;https://rufus.ie/en/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A Pen Drive with at least 8 GB Storage (16GB or more recommended)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the step by step guide for Windows Installation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First backup all your data in the computer, as even though it's possible to not delete any data while reinstalling Windows, it's better to clear everything and get a fresh start.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Rufus, and connect your pen drive to your system. You should be able to see the pen drive's name at the top of your Rufus Window. In the boot selection option, press select and choose the Windows 11 ISO downloaded from the official Microsoft Link. Press Start. When Prompted for Windows Customization, Choose the options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(Optional) Remove requirements for 4GB+ RAM, Secure Boot and TPM 2.0&lt;/li&gt;
&lt;li&gt;Remove Requirement for an online Microsoft Account&lt;/li&gt;
&lt;li&gt;Create a local account with username: &lt;/li&gt;
&lt;li&gt;Disable data collection (skip privacy option)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the setup is finished, boot into boot options, and select the pen drive to boot from. To find the boot options for your laptop/desktop, you can google the model, or use: &lt;a href="https://techofide.com/blogs/boot-menu-option-keys-for-all-computers-and-laptops-updated-list-2021-techofide/" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; to find the key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;During Windows Installation, a few things must be considered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose English World as time and currency. This will remove most of the bloatware.&lt;/li&gt;
&lt;li&gt;If your installation media is missing during disk selection, you might need to manually install Intel Rapid Storage Technology Drivers (Intel RST). Download the drivers from &lt;a href="https://www.mediafire.com/file/l2di0f6wpn77ghv/Intel_RST_VMD_Controller_9A0B.zip/file" rel="noopener noreferrer"&gt;here&lt;/a&gt;, and extract them to the installation pen drive. When prompted, choose load manually and browse to the folder containing the driver. Choose any one from the list.&lt;/li&gt;
&lt;li&gt;Delete all the partitions related to Windows. If you do not want to save ANY data (such as D: E:) you can delete all the present partitions before hitting next.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once Your System wants to reboot after installation, remove the installation pen drive.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Initial Windows Setup
&lt;/h3&gt;

&lt;p&gt;During the Windows 11 Initial setup screen, if you chose your region as English World, it may give an error. You can safely skip this. Most of the things it will ask shouldn't be a bother. However if it does ask something, here's the tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If it asks for data collection options, turn them all off.&lt;/li&gt;
&lt;li&gt;If it asks for Microsoft Account Login, either skip it, or if the option is not given, press &lt;code&gt;Shift + f10&lt;/code&gt; to launch CMD, then type the command &lt;code&gt;oobe\bypassnro&lt;/code&gt; which will restart the computer. Another option if this gives an issue is to again, press &lt;code&gt;Shift + f10&lt;/code&gt; and then in CMD type &lt;code&gt;ipconfig /release&lt;/code&gt; then go back from the login screen, and you should have the option to setup a local account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once Windows Launches, make sure to set your region back to get a working Microsoft Store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to settings app&lt;/li&gt;
&lt;li&gt;On the left side go to the &lt;code&gt;Time and Language&lt;/code&gt; section&lt;/li&gt;
&lt;li&gt;Go to the &lt;code&gt;language and region&lt;/code&gt; Tab&lt;/li&gt;
&lt;li&gt;Update your &lt;code&gt;Country or Region&lt;/code&gt; to the correct one&lt;/li&gt;
&lt;li&gt;Go back and then in the &lt;code&gt;Date &amp;amp; Time&lt;/code&gt; Tab&lt;/li&gt;
&lt;li&gt;Select the timezone where you live&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once this is done, you should be able to use Microsoft Store as normal. &lt;/p&gt;

&lt;p&gt;Now you can:&lt;/p&gt;



&lt;h3&gt;
  
  
  Update Windows
&lt;/h3&gt;

&lt;p&gt;Firstly update your Windows System. This will get the latest drivers and system update. Windows should automatically take care of this, however to make sure,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the settings app&lt;/li&gt;
&lt;li&gt;Head Over to the Windows Update tab on the left&lt;/li&gt;
&lt;li&gt;Press check for updates, or update all if present&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  Update Nvidia Driver
&lt;/h3&gt;

&lt;p&gt;If you have an Nvidia Graphics Card you need to make sure it's updated. There are two ways to update the driver for Nvidia Graphics Card:&lt;/p&gt;

&lt;p&gt;First way is to update using Nvidia Control Panel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right Click on the windows desktop and select &lt;code&gt;Nvidia Control Panel&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to the help menu and select updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;OR&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Second Method is to manually download the driver&lt;br&gt;
    - First let's figure out the Graphics Card you have. If you already know it, skip this step. Press &lt;code&gt;Windows Key + R&lt;/code&gt; to open run dialog, and type &lt;code&gt;dxdiag&lt;/code&gt; and press ok. Once the window open, go the tabs on the top labelled &lt;code&gt;display&lt;/code&gt; to check the one with Nvidia Graphics Card. Note down the name.&lt;br&gt;&lt;br&gt;
    - Navigate to &lt;a href="https://www.nvidia.com/en-us/drivers/" rel="noopener noreferrer"&gt;https://www.nvidia.com/en-us/drivers/&lt;/a&gt; &lt;br&gt;
    - In the search field, search the name of your graphics card and open the relevant one.&lt;br&gt;
    - Download the Latest Nvidia Game Ready Driver&lt;br&gt;
    - Open the installer and follow the on screen prompts. DO NOT INSTALL Geforce Experience App unless you have a really good reason to. &lt;/p&gt;



&lt;h3&gt;
  
  
  Use Chris Titus Tech Tool
&lt;/h3&gt;

&lt;p&gt;The YouTuber Chris Titus Tech has created a really great and simple to use app which allows to make automatic tweaks to Windows. To use the tool:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search Powershell in start menu, right click and run as administrator&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;irm christitus.com/win | iex&lt;/code&gt; in the window and hit enter&lt;/li&gt;
&lt;li&gt;Once the window launches, head over to the &lt;code&gt;Tweaks&lt;/code&gt; tab up top, and from the &lt;code&gt;Recommended Selections&lt;/code&gt;, select the &lt;code&gt;standard&lt;/code&gt; option&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Run Tweaks&lt;/code&gt; at the bottom &lt;/li&gt;
&lt;li&gt;DO NOT USE THE ULTIMATE PERFORMANCE POWER PLAN. Unless you are running a really high end PC with AIO Coolers, it's probably gonna cause more issues than fix them. I'll talk in the next section about what's the best power options.&lt;/li&gt;
&lt;li&gt;Once Finished, head over to the &lt;code&gt;Updates&lt;/code&gt; tab at the top, and select the &lt;code&gt;Security (Recommended) Settings&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Exit the program and powershell&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Change the power plan
&lt;/h3&gt;

&lt;p&gt;Now, let's manually adjust the power plan to reduce the temperatures and improve performance.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search for &lt;code&gt;Edit Power Plan&lt;/code&gt; in the start menu and open it.&lt;/li&gt;
&lt;li&gt;Make sure you are using the &lt;code&gt;balanced power mode&lt;/code&gt;. Ultimate or High Performance will lead to more issues&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Change Advanced Power Settings&lt;/code&gt; and change the following settings:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Wireless Adapter Settings
    - Power Saving Mode
        - On Battery: Medium Power Settings
        - Plugged in: Maximum Performance

- USB Settings
    - USB Selective Suspend Settings
        - On Battery: Disabled
        - Plugged in: Disabled

- Intel ® Graphics Settings
    - Intel ® Graphics Power Plan
        - On Battery: Balanced
        - Plugged in: Maximum Performance

- PCI Express
    - Link State Power Management
        - On Battery: Maximum Power Savings
        - Plugged in: Off

- Processor Power Management
    - Minimum Processor State
        - On Battery: 5%
        - Plugged in: 5%

    - System Cooling Policy
        - On Battery: Active
        - Plugged in: Active

    - Maximum Processor State
        - On Battery: 100%
        - Plugged in: 100%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setup Auto Defragment For Your Hard Disk
&lt;/h3&gt;

&lt;p&gt;SKIP THIS IF YOU ARE USING AN SSD. In a hard drive the data can become scattered to different places. Hence the disk head has to jump a lot more between places to get data which definitely slows it down. This will only help in case you are using a hard disk. To check if you are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for &lt;code&gt;Defragment and Optimize Drives&lt;/code&gt; in the start menu&lt;/li&gt;
&lt;li&gt;In the listed drives, check the column named &lt;code&gt;Media Type&lt;/code&gt;. If it says &lt;code&gt;Solid State Drive&lt;/code&gt; skip this section.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the drive is a &lt;code&gt;Hard Disk Drive&lt;/code&gt;, then set up auto defragment as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the &lt;code&gt;Defragment&lt;/code&gt; Window, under the &lt;code&gt;Scheduled Optimization&lt;/code&gt; press &lt;code&gt;change settings&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the new window, tick &lt;code&gt;Run on a schedule&lt;/code&gt; with frequency &lt;code&gt;Weekly&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Leave the rest default and hit ok and close the defragment window.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  Remove the unnecessary apps
&lt;/h3&gt;

&lt;p&gt;This step will allow you to reduce the number of background processes, and also free up extra space. To remove unwanted or unnecessary apps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the &lt;code&gt;Settings&lt;/code&gt; app from start menu&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;Apps&lt;/code&gt; in the left tab&lt;/li&gt;
&lt;li&gt;Open the &lt;code&gt;Installed Apps&lt;/code&gt; tab&lt;/li&gt;
&lt;li&gt;Go through the list and remove all the apps you don't use. If there are some which you are uncertain whether or not can be uninstalled, a simple google search should help. Search something like &lt;code&gt;Is &amp;lt;app_name&amp;gt; safe to uninstall&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  Disable Unnecessary Startup Programs
&lt;/h3&gt;

&lt;p&gt;Some apps start when Windows starts, effectively slowing down the boot time. You can disable these apps by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Press &lt;code&gt;Ctrl + Shift + Esc&lt;/code&gt; or search for &lt;code&gt;Task Manager&lt;/code&gt; in the start menu and open it&lt;/li&gt;
&lt;li&gt;In the Task Manager, go to the tab on the left which says &lt;code&gt;Startup Apps&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Disable any apps you don't want to start automatically by right clicking on the app name, and selecting disable.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  Use a custom DNS
&lt;/h3&gt;

&lt;p&gt;A DNS is a service which converts the URL of websites (such as &lt;a href="http://www.google.com" rel="noopener noreferrer"&gt;www.google.com&lt;/a&gt;) to it's IP Address (such as 142.251.xx.x). The default ISP DNS can be slow, and they can also track which sites you may be visiting. It's bette to use a custom DNS.&lt;/p&gt;

&lt;p&gt;There are two DNS I recommend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloudflare (Loads websites faster): 1.1.1.1 &amp;amp; 1.0.0.1&lt;/li&gt;
&lt;li&gt;Adguard (Blocks ads on most sites and apps) : 94.140.14.14 &amp;amp; 94.140.15.15&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To use one of these, or some other DNS you might have found online:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search &lt;code&gt;Control Panel&lt;/code&gt; in the start menu&lt;/li&gt;
&lt;li&gt;In the windows, either select &lt;code&gt;Network and Internet&lt;/code&gt; and then &lt;code&gt;Network and Sharing Center&lt;/code&gt; or &lt;code&gt;Network and Sharing Center&lt;/code&gt; if present directly.&lt;/li&gt;
&lt;li&gt;In the left panel, select &lt;code&gt;Change Adapter Settings&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Choose the Wi-Fi Network to which you are connected. Right click on it and choose &lt;code&gt;Properties&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In the list double click the option labelled &lt;code&gt;Internet Protocol Version 4 (TCP/IPv4)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In the bottom section, choose the option &lt;code&gt;Use the following DNS Server Addresses:&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In the preferred address write the main DNS Address (for cloudflare it's 1.1.1.1)&lt;/li&gt;
&lt;li&gt;In the alternate address write the secondary DNS Address (for cloudflare it's 1.0.0.1)&lt;/li&gt;
&lt;li&gt;Hit ok and exit.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  (Optional) Disable/Reduce Turbo Boost
&lt;/h3&gt;

&lt;p&gt;If you are on a computer without a good cooling system, such as a laptop, it tends to be better to disable turbo boost. Turbo boost is the technology which boosts the CPU to higher frequencies, however it also generates more heat. Reducing Turbo Boost should keep the heat to minimum, allowing for better performance. There shouldn't be any performance drop, though your experience may vary so make sure to test it well.&lt;/p&gt;

&lt;p&gt;To Disable/Reduce Turbo Boost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Press &lt;code&gt;Windows Key + R&lt;/code&gt; to launch the run window&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;regedit.exe&lt;/code&gt; in the field and press ok&lt;/li&gt;
&lt;li&gt;In the registry editor window, in the address at the top where it probably says &lt;code&gt;Computer&lt;/code&gt; or &lt;code&gt;HKEY....&lt;/code&gt; write the following: &lt;code&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\be337238-0d82-4146-a960-4f3749d470c7&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;On the right panel, double click on the file called &lt;code&gt;Attributes&lt;/code&gt; and modify the value from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt;. The data should read &lt;code&gt;0x00000002 (2)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Search for &lt;code&gt;Edit Power Plan&lt;/code&gt; in the start menu and open it.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Change Advanced Power Settings&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Adjust the settings:

&lt;ul&gt;
&lt;li&gt;Processor Power Management

&lt;ul&gt;
&lt;li&gt;Processor Performance Boost Mode

&lt;ul&gt;
&lt;li&gt;On Battery: Disabled&lt;/li&gt;
&lt;li&gt;Plugged in: Disabled / Efficient Aggressive (Test which works best for you)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;



&lt;h3&gt;
  
  
  (Optional) Use ISLC for low end PC
&lt;/h3&gt;

&lt;p&gt;The Intelligent Standby List Cleaner is an utility which frees up memory taken by programs running in tha background. If you have a good amount of memory (RAM) then usage of this tool is discouraged. However if you have limited memory, here's the step by step guide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download ISLC tool from &lt;a href="https://www.wagnardsoft.com/forums/viewtopic.php?t=1256" rel="noopener noreferrer"&gt;https://www.wagnardsoft.com/forums/viewtopic.php?t=1256&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Open and Extract the files anywhere (it will permanently stay there so choose a permanent location for the tool)&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;Intelligent Standby List Cleaner ISLC&lt;/code&gt; as administrator&lt;/li&gt;
&lt;li&gt;Tick the &lt;code&gt;Start ISLC minimized and auto Start monitoring&lt;/code&gt; and &lt;code&gt;Launch ISLC on user logon. (Task Scheduler)&lt;/code&gt; option. This will automatically run the app on each boot.&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;enable custom timer resolution&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Adjust the value of &lt;code&gt;Wanted Timer Resolution&lt;/code&gt; to &lt;code&gt;0.5000&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Press the start button and minimize the software&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  (Risky) Undervolting
&lt;/h3&gt;

&lt;p&gt;Undervolting is an entire process. Here's the basics - The more power something uses, the more heat it generates - The more heat in the system, the slower it has to run to combat the heat - called as &lt;code&gt;Thermal Throttling&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In essence, while you may think using more power helps your system run faster, unless it can be properly cooled down, it actually slows down the pc to keep the CPU from frying itself.&lt;/p&gt;

&lt;p&gt;This is where undervolting comes in. Undervolting is the process of limiting, or more accurately, offsetting the voltage you supply to your processor or the GPU, to allow it to run cooler, and get more performance per watt out of your machine without it thermal throttling&lt;/p&gt;

&lt;p&gt;Since this is a lot risky, I will soon be creating a seperate guide on undervolting your GPU and CPU individually so you don't end up with a non-functioning device.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;These steps all should allow your pc to run better, using less power, yet giving more performance. I will be creating separate guides on CPU and GPU Undervolting. And I will also try my best to keep this guide updated. However these modifications may end up messing with your system, so try them out at your own risk.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>optimization</category>
      <category>windows</category>
      <category>microsoft</category>
    </item>
  </channel>
</rss>
