<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://junhaohu-tech.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://junhaohu-tech.github.io/" rel="alternate" type="text/html" /><updated>2025-11-21T20:15:32+00:00</updated><id>https://junhaohu-tech.github.io/feed.xml</id><title type="html">JH H</title><subtitle>Aspiring PhD student interested in distributed systems and databases. I enjoy building reliable data-intensive systems and understanding the theory and practice behind them.</subtitle><author><name>JH H</name><email>none@example.org</email></author><entry><title type="html">TiDB Hackathon 2022 — Analysis</title><link href="https://junhaohu-tech.github.io/competitions/competition-tidb-hackathon/" rel="alternate" type="text/html" title="TiDB Hackathon 2022 — Analysis" /><published>2025-11-15T00:00:00+00:00</published><updated>2025-11-15T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/competitions/competition-tidb-hackathon</id><content type="html" xml:base="https://junhaohu-tech.github.io/competitions/competition-tidb-hackathon/"><![CDATA[<h1 id="-tidb-hackathon-2022">🏆 TiDB Hackathon 2022</h1>
<p>A detailed analysis of TiDB Hackathon 2022’s Application Track, focusing on the top three award-winning projects—DataDance, Yunji, and Mirror. This write-up summarizes their architectures, design trade-offs, and engineering challenges from academic, system-engineering, and participant perspectives.</p>

<hr />

<h1 id="1-competition-overview">1. Competition Overview</h1>

<p><strong>Competition:</strong> TiDB Hackathon 2022<br />
<strong>Track:</strong> Application Group<br />
<strong>Theme:</strong> <em>Possibility at Scale</em><br />
<strong>Official page:</strong> https://tidb.net/events/hackathon2022</p>

<p>TiDB Hackathon is the flagship annual event organized by PingCAP and the TiDB open-source community.<br />
It is widely regarded as one of the most influential hackathons in the database and distributed-systems ecosystem.</p>

<p>The <strong>2022 edition</strong> brought together:</p>

<ul>
  <li><strong>303 participants</strong></li>
  <li><strong>86 teams</strong></li>
  <li>engineers, researchers, database kernel developers, and open-source contributors</li>
</ul>

<p>The Application Track challenges participants to build <strong>real-world, large-scale distributed applications</strong> powered by TiDB’s HTAP capabilities, TiFlash, TiKV, and related ecosystem tools.</p>

<p>The hackathon requires teams to:</p>

<ul>
  <li>Propose an idea (RFC)</li>
  <li>Build a working prototype in 48 hours</li>
  <li>Demonstrate scalability &amp; real engineering depth</li>
  <li>Deliver a polished live demo</li>
</ul>

<p>Evaluation criteria:</p>

<ol>
  <li>Innovation</li>
  <li>Engineering completeness</li>
  <li>Scalability</li>
  <li>Architectural soundness</li>
  <li>Community usefulness</li>
  <li>Demo quality</li>
</ol>

<hr />

<h1 id="2-the-winning-projects-application-track">2. The Winning Projects (Application Track)</h1>

<p>This write-up examines three award-winning projects:</p>

<h3 id="-first-prize--datadance">🥇 First Prize — <strong>DataDance</strong></h3>
<p>https://github.com/datadance-fun/DataDance</p>

<h3 id="-second-prize--yunji">🥈 Second Prize — <strong>Yunji</strong></h3>
<p>https://github.com/VelocityLight/yunji</p>

<h3 id="-second-prize--mirror">🥈 Second Prize — <strong>Mirror</strong></h3>
<p>https://github.com/mirror-data/mirror</p>

<hr />

<h1 id="3-project-analyses">3. Project Analyses</h1>

<h2 id="31-first-prize--datadance">3.1 First Prize — DataDance</h2>
<p><strong>Goal:</strong><br />
A real-time data transformation platform (dbt-like + incremental ETL) built on TiDB.</p>

<h3 id="key-features">Key Features</h3>
<ul>
  <li>SQL-based workflow definitions</li>
  <li>DAG transformation graph</li>
  <li>Incremental recomputation with minimal deltas</li>
  <li>TiCDC-triggered updates</li>
  <li>Materialized outputs stored in TiDB/TiFlash</li>
  <li>Web UI for pipeline visualization</li>
</ul>

<h3 id="architecture-overview">Architecture Overview</h3>

<p>User SQL → Parser → DAG Builder → Task Scheduler → Executors
↓ ↑
Metadata (TiDB)</p>

<h3 id="strengths">Strengths</h3>
<ul>
  <li>Very strong engineering completeness for a 48-hour hackathon</li>
  <li>Clear real-world use case</li>
  <li>Seamless integration with TiDB HTAP</li>
  <li>Professional UI + strong system story</li>
</ul>

<hr />

<h2 id="32-second-prize--yunji">3.2 Second Prize — Yunji</h2>
<p>https://github.com/VelocityLight/yunji</p>

<p><strong>Goal:</strong><br />
A multi-tenant, cloud-native user analytics platform for real-time metrics &amp; behavioral analysis.</p>

<h3 id="key-features-1">Key Features</h3>
<ul>
  <li>Multi-tenant isolation</li>
  <li>Event ingestion → normalization → TiDB</li>
  <li>Real-time user profile store</li>
  <li>Metrics dashboard backed by TiFlash</li>
  <li>Plugin-based analytics</li>
</ul>

<h3 id="architecture-overview-1">Architecture Overview</h3>

<p>Event Stream → Collector → Normalizer → TiDB
↓
Analytics API
↓
Dashboard / UI</p>

<h3 id="strengths-1">Strengths</h3>
<ul>
  <li>Clean schema design for event analytics</li>
  <li>HTAP-aware architecture</li>
  <li>Balanced full-stack system</li>
  <li>High practical value</li>
</ul>

<hr />

<h2 id="33-second-prize--mirror">3.3 Second Prize — Mirror</h2>
<p>https://github.com/mirror-data/mirror</p>

<p><strong>Goal:</strong><br />
A developer-friendly visualization and introspection tool for TiDB clusters.</p>

<h3 id="key-features-2">Key Features</h3>
<ul>
  <li>Visual schema explorer</li>
  <li>Column statistics &amp; profiling</li>
  <li>Query insight dashboards</li>
  <li>Real-time table previews</li>
  <li>ER diagram &amp; dependency mapping</li>
</ul>

<h3 id="architecture-overview-2">Architecture Overview</h3>

<p>Frontend (React) → API Gateway → TiDB Information Schema / Stats
↓
Profiling &amp; Insights Engine</p>

<h3 id="strengths-2">Strengths</h3>
<ul>
  <li>Excellent UX and presentation polish</li>
  <li>Fills a needed gap in TiDB developer tooling</li>
  <li>Lightweight, usable, easy to integrate</li>
</ul>

<hr />

<h1 id="4-technical-analysis">4. Technical Analysis</h1>

<h2 id="41-professor--research-perspective">4.1 Professor / Research Perspective</h2>
<p>A researcher may focus on:</p>

<ul>
  <li>HTAP execution patterns (TiDB + TiFlash)</li>
  <li>DAG-based incremental view maintenance (DataDance)</li>
  <li>Multi-tenant metadata modeling (Yunji)</li>
  <li>Schema and stats introspection (Mirror)</li>
  <li>Hybrid streaming/batch pipelines</li>
  <li>Query pushdown and cost-based execution</li>
</ul>

<p>These projects represent modern directions in distributed SQL systems.</p>

<hr />

<h2 id="42-systems-engineer-perspective">4.2 Systems Engineer Perspective</h2>

<h3 id="engineering-topics-of-interest">Engineering topics of interest:</h3>
<ul>
  <li>Pipeline ingestion architectures</li>
  <li>Metadata schema design</li>
  <li>Consistency models for incremental pipelines</li>
  <li>Avoiding full recomputation via deltas</li>
  <li>TiFlash as analytical accelerator</li>
  <li>Performance considerations under concurrency</li>
</ul>

<h3 id="common-design-trade-offs">Common design trade-offs:</h3>
<ul>
  <li>SQL vs DSL for workflow definitions</li>
  <li>Metadata stored inside TiDB vs external store</li>
  <li>Push vs pull data refresh</li>
  <li>Horizontal scaling patterns</li>
</ul>

<hr />

<h2 id="43-contestant-perspective">4.3 Contestant Perspective</h2>
<p>Things a participant would care about:</p>

<ul>
  <li>What project ideas are competitive?</li>
  <li>What can be realistically built in 48 hours?</li>
  <li>UI vs backend effort allocation</li>
  <li>How much demo polish is needed?</li>
  <li>What factors matter most to judges?</li>
</ul>

<h3 id="observed-winning-patterns">Observed Winning Patterns</h3>
<ul>
  <li>Clean, end-to-end user story</li>
  <li>Practical use case deeply tied to TiDB</li>
  <li>Strong visual demo</li>
  <li>Real code, not just concepts</li>
  <li>Architectural clarity</li>
</ul>

<hr />

<h1 id="5-high-scoring-architecture-patterns">5. High-Scoring Architecture Patterns</h1>

<p>Across DataDance, Yunji, and Mirror, common patterns emerge:</p>

<h3 id="1-tidb-as-the-primary-metadata--transactional-store">1. TiDB as the primary metadata &amp; transactional store</h3>
<p>Used for: schemas, pipeline state, configs, offsets, profiles.</p>

<h3 id="2-tiflash-as-analytical-compute">2. TiFlash as analytical compute</h3>
<p>Used for: aggregations, segmentation, statistics, dashboards.</p>

<h3 id="3-dag-or-streaming-execution-models">3. DAG or streaming execution models</h3>
<p>(DataDance and Yunji)</p>

<h3 id="4-strong-frontend-polish">4. Strong frontend polish</h3>
<p>Yunji &amp; Mirror show UI matters.</p>

<h3 id="5-cloud-native-deployment">5. Cloud-native deployment</h3>
<p>Most teams used Docker to simplify demo.</p>

<hr />

<h1 id="6-community-code-references">6. Community Code References</h1>

<h3 id="-datadance-first-prize">🥇 DataDance (First Prize)</h3>
<p>https://github.com/datadance-fun/DataDance</p>

<h3 id="-yunji-second-prize">🥈 Yunji (Second Prize)</h3>
<p>https://github.com/VelocityLight/yunji</p>

<h3 id="-mirror-second-prize">🥈 Mirror (Second Prize)</h3>
<p>https://github.com/mirror-data/mirror</p>

<p>These repositories serve as excellent references for:</p>

<ul>
  <li>incremental computation</li>
  <li>schema design</li>
  <li>clean data ingestion pipelines</li>
  <li>scalable HTAP architectures</li>
  <li>developer-oriented tooling</li>
</ul>

<hr />

<h1 id="7-reflection--conclusion">7. Reflection &amp; Conclusion</h1>

<p>TiDB Hackathon 2022 Application Track brings together innovation in:</p>

<ul>
  <li>distributed SQL</li>
  <li>HTAP workloads</li>
  <li>real-time data transformations</li>
  <li>cloud-native SaaS analytics</li>
  <li>developer observability tools</li>
</ul>

<p>From a <strong>research angle</strong>, these projects demonstrate practical prototypes of active research areas such as incremental view maintenance, hybrid streaming workloads, and HTAP optimization.</p>

<p>From a <strong>systems-engineering angle</strong>, they illustrate clean architecture boundaries, correct use of TiDB/TiFlash, and realistic distributed workload patterns.</p>

<p>From a <strong>contestant angle</strong>, the lesson is clear:</p>

<blockquote>
  <p><strong>The strongest projects do not reinvent TiDB—they extend it in impactful, meaningful, and highly usable ways.</strong></p>
</blockquote>

<p>TiDB Hackathon remains a unique environment where distributed systems innovation meets real-world engineering constraints, producing ideas and prototypes that often evolve into community contributions.</p>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="competitions" /><summary type="html"><![CDATA[A high-level analysis of TiDB Hackathon 2022, examining its open-ended, innovation-driven challenges across TiDB/TiKV kernel development, distributed-systems engineering, and large-scale application design.]]></summary></entry><entry><title type="html">Copier: Rethinking Memory Copy as a First-Class OS Service — SOSP 2025 Paper Review</title><link href="https://junhaohu-tech.github.io/paper-notes/understanding-copier/" rel="alternate" type="text/html" title="Copier: Rethinking Memory Copy as a First-Class OS Service — SOSP 2025 Paper Review" /><published>2025-11-15T00:00:00+00:00</published><updated>2025-11-15T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/paper-notes/understanding-copier</id><content type="html" xml:base="https://junhaohu-tech.github.io/paper-notes/understanding-copier/"><![CDATA[<h1 id="paper-review">Paper Review</h1>
<p><strong>How to Copy Memory? Coordinated Asynchronous Copy as a First-Class OS Service</strong><br />
<em>Jingkai He, Yunpeng Dong, Dong Du (Shanghai Jiao Tong University);<br />
Mo Zou, Zhitai Yu, Yuxin Ren, Ning Jia (Huawei Technologies);<br />
Yubin Xia, Haibo Chen (Shanghai Jiao Tong University)</em><br />
<strong>SOSP 2025</strong></p>

<p>This review follows an 8-section structure tailored for distributed-systems and OS researchers, engineers, and students seeking to extract high-level ideas and design insights without reading the entire 20-page SOSP paper.</p>

<hr />

<h1 id="1-why-this-paper-matters--the-pain-point">1. Why This Paper Matters — The Pain Point</h1>

<p>In modern operating systems, <strong>memory copy</strong> remains a significant and persistent performance bottleneck.<br />
It directly impacts:</p>

<ul>
  <li>system calls (e.g., <code class="language-plaintext highlighter-rouge">recv</code>, <code class="language-plaintext highlighter-rouge">send</code>)</li>
  <li>IPC (Android Binder, pipes, shared memory)</li>
  <li>high-I/O workloads (databases, KV stores, proxies, RPC servers)</li>
  <li>memory-intensive applications (protobuf, video codecs, ML pipelines)</li>
</ul>

<p>Even though memcpy looks trivial, <strong>data movement dominates both CPU cycles and memory bandwidth</strong>—often more than computation itself.</p>

<p>Existing solutions have limitations:</p>

<h3 id="zero-copy"><strong>Zero-copy</strong></h3>
<ul>
  <li>requires page alignment</li>
  <li>fails for multi-copy/CoW scenarios</li>
  <li>unsafe (TOCTTOU risks)</li>
  <li>only helps large chunks (Linux ≥10KB, zIO ≥16KB)</li>
</ul>

<h3 id="hardware-accelerated-copy-dma--simd"><strong>Hardware-accelerated copy (DMA / SIMD)</strong></h3>
<ul>
  <li>user applications cannot directly use DMA</li>
  <li>kernel SIMD (AVX) suffers heavy state-save overhead</li>
  <li>hard to schedule across subsystems</li>
  <li>low global utilization</li>
</ul>

<h3 id="synchronous-memcpy"><strong>Synchronous memcpy</strong></h3>
<ul>
  <li>blocks the caller</li>
  <li>cannot overlap communication and computation</li>
  <li>cannot hide latency</li>
</ul>

<hr />

<h1 id="2-problem-formulation--whats-wrong-with-todays-os-model">2. Problem Formulation — What’s Wrong With Today’s OS Model?</h1>

<p>Memory copy today is:</p>

<ul>
  <li><strong>scattered</strong> across the entire OS and application ecosystem</li>
  <li><strong>synchronous</strong></li>
  <li><strong>uncoordinated</strong> (each subsystem uses its own memcpy path)</li>
  <li><strong>unoptimizable</strong> at global scale</li>
  <li><strong>blind</strong> to hardware heterogeneity (CPU SIMD, DMA engines)</li>
</ul>

<p>As the authors summarize:</p>

<blockquote>
  <p>“Copying is everywhere, but coordinated nowhere.”</p>
</blockquote>

<p>The paper argues that memcpy must be elevated into <strong>a first-class, OS-managed asynchronous service</strong>, enabling:</p>

<ol>
  <li><strong>asynchrony</strong> → overlap copy &amp; compute</li>
  <li><strong>global optimization</strong> → eliminate redundant copies</li>
  <li><strong>hardware orchestration</strong> → jointly schedule CPU+DMA</li>
  <li><strong>cross-subsystem coordination</strong> → networking, paging, IPC, and filesystems</li>
</ol>

<p>This leads to the core contribution: <strong>Copier</strong>.</p>

<hr />

<h1 id="3-key-idea--copier-coordinated-asynchronous-copy-as-an-os-service">3. Key Idea — Copier: Coordinated Asynchronous Copy as an OS Service</h1>

<p>The central idea:</p>

<blockquote>
  <p><strong>Turn memory copy into an OS-level asynchronous service</strong>, similar to async I/O,<br />
exposing a unified interface for both applications and kernel subsystems.</p>
</blockquote>

<h3 id="copier-provides">Copier provides:</h3>
<ul>
  <li>asynchronous copy submission</li>
  <li>dependency tracking</li>
  <li>copy–use pipelining</li>
  <li>unified hardware scheduling (AVX + DMA)</li>
  <li>global copy absorption (eliminate unnecessary middle copies)</li>
  <li>fairness, isolation, and cgroup integration</li>
  <li>proactive fault-handling for page faults</li>
</ul>

<h3 id="why-coordinated-and-asynchronous-both-matter">Why “coordinated” and “asynchronous” both matter?</h3>
<ul>
  <li><strong>asynchronous</strong> makes copy overlap with compute</li>
  <li><strong>coordinated</strong> scheduling lets OS globally optimize and eliminate redundant tasks</li>
  <li><strong>first-class service</strong> means all subsystems share the same mechanism (network, FS, IPC, VM)</li>
</ul>

<p>This is the fundamental conceptual advancement.</p>

<hr />

<h1 id="4-system-design">4. System Design</h1>

<p>Copier’s architecture combines abstractions, dependency tracking, heterogeneous hardware scheduling, and OS-level management.<br />
Below are the essential components.</p>

<hr />

<h2 id="41-copier-abstraction">4.1 Copier Abstraction</h2>

<h3 id="three-queues"><strong>Three queues</strong></h3>
<ul>
  <li><strong>Copy Queue</strong> — asynchronous copy requests</li>
  <li><strong>Sync Queue</strong> — synchronous promotion via <code class="language-plaintext highlighter-rouge">csync()</code></li>
  <li><strong>Handler Queue</strong> — completion callbacks</li>
</ul>

<h3 id="segment-based-copy"><strong>Segment-based Copy</strong></h3>
<p>Breaks large copies into <strong>segments</strong>, enabling:</p>

<ul>
  <li>fine-grained state updates</li>
  <li>early consumption of partially copied data</li>
  <li>true copy–use pipelining</li>
  <li>better concurrency under multi-client access</li>
</ul>

<h3 id="task-promotion-and-csync"><strong>Task Promotion and <code class="language-plaintext highlighter-rouge">csync()</code></strong></h3>
<p><code class="language-plaintext highlighter-rouge">csync()</code> allows a client to say: “I am about to use this data; promote required segments now.”</p>

<p>This solves:</p>

<ul>
  <li>head-of-line blocking</li>
  <li>dependency delays</li>
  <li>unpredictable latency</li>
</ul>

<hr />

<h2 id="42-dependency-tracking">4.2 Dependency Tracking</h2>

<p>Two types of dependencies must be preserved:</p>

<h3 id="cross-queue-barriers"><strong>Cross-Queue Barriers</strong></h3>
<p>Using <strong>syscall trap / return events</strong> to reconcile order between user-mode and kernel-mode tasks.</p>

<h3 id="data-dependency-tracking"><strong>Data Dependency Tracking</strong></h3>
<p>Ensures correctness under reordering, e.g., when <code class="language-plaintext highlighter-rouge">csync()</code> accelerates segments.</p>

<hr />

<h2 id="43-heterogeneous-hardware-coordination">4.3 Heterogeneous Hardware Coordination</h2>

<p>Copier uses <strong>task piggybacking</strong>:</p>

<ul>
  <li>large contiguous segments → DMA</li>
  <li>small / misaligned segments → AVX2</li>
  <li>DMA tasks <em>piggyback</em> onto AVX tasks to hide submission overhead</li>
</ul>

<p>This improves:</p>

<ul>
  <li>bandwidth utilization</li>
  <li>latency</li>
  <li>CPU overhead</li>
  <li>cache behavior</li>
</ul>

<hr />

<h2 id="44-copy-absorption-global-redundancy-elimination">4.4 Copy Absorption (Global Redundancy Elimination)</h2>

<p>Copier can eliminate intermediate copies such as:</p>

<p>Kernel Buffer → Intermediate Buffer → Destination</p>

<p>becoming:</p>

<p>Kernel Buffer → Destination</p>

<p>It achieves this via:</p>

<ul>
  <li>segment descriptors</li>
  <li>dependency tracking</li>
  <li><strong>lazy copy tasks</strong> (almost never executed; used for dependency absorption)</li>
</ul>

<p>This is one of the biggest performance wins.</p>

<hr />

<h2 id="45-multi-client-service-management">4.5 Multi-Client Service Management</h2>

<h3 id="resource-isolation"><strong>Resource Isolation</strong></h3>
<p>Extends cgroup to track copy length as the resource.</p>

<h3 id="fair-scheduling"><strong>Fair Scheduling</strong></h3>
<p>A CFS-like scheduler ensures fair bandwidth across clients.</p>

<h3 id="proactive-fault-handling"><strong>Proactive Fault Handling</strong></h3>
<p>Lock virtual → physical mappings <em>before</em> issuing copy, ensuring DMA never faults inside Copier context.</p>

<hr />

<h1 id="5-evaluation--how-much-faster">5. Evaluation — How Much Faster?</h1>

<h3 id="macro-benchmarks"><strong>Macro Benchmarks</strong></h3>
<ul>
  <li>Up to <strong>158% throughput improvement</strong> through AVX2+DMA coordination</li>
  <li>For OS services: significant latency reduction for
    <ul>
      <li><code class="language-plaintext highlighter-rouge">recv()</code> / <code class="language-plaintext highlighter-rouge">send()</code></li>
      <li>Android Binder IPC</li>
      <li>CoW page-fault handling</li>
    </ul>
  </li>
</ul>

<h3 id="application-workloads"><strong>Application Workloads</strong></h3>
<ul>
  <li><strong>Redis latency ↓ up to 43.4%</strong></li>
  <li><strong>TinyProxy throughput ↑ 7.2%–32.3%</strong> via copy absorption</li>
  <li><strong>Protobuf, OpenSSL, and video decoding</strong> improved by 3%–33%</li>
</ul>

<h3 id="cpu-efficiency"><strong>CPU Efficiency</strong></h3>
<ul>
  <li>Reduced cache pollution</li>
  <li>Non-copy code CPI ↓ 4%–16%</li>
  <li>Copy-as-a-service frees CPU pipeline for useful work</li>
</ul>

<p>The evaluation shows the design translates directly into real performance gains across multiple workloads.</p>

<hr />

<h1 id="6-connections-to-prior-work">6. Connections to Prior Work</h1>

<p>The authors position Copier relative to prior approaches:</p>

<h3 id="rowclone--dram-internal-copy"><strong>RowClone / DRAM-internal copy</strong></h3>
<ul>
  <li>requires hardware modification</li>
  <li>not applicable to general workloads</li>
</ul>

<h3 id="zero-copy-networking--filesystem"><strong>Zero-copy networking / filesystem</strong></h3>
<ul>
  <li>strict size &amp; alignment requirements</li>
  <li>unsafe for multi-copy scenarios</li>
</ul>

<h3 id="userspace-dma-frameworks"><strong>Userspace DMA frameworks</strong></h3>
<ul>
  <li>privilege barriers</li>
  <li>unsafe for general applications</li>
</ul>

<h3 id="os-as-a-service-trends"><strong>OS-as-a-service trends</strong></h3>
<p>Similar to:</p>
<ul>
  <li>TAS (TCP acceleration as a service)</li>
  <li>FlexSC (async syscall)</li>
  <li>io_uring (async I/O)</li>
</ul>

<h3 id="copiers-uniqueness">Copier’s uniqueness:</h3>
<ul>
  <li>works <strong>without hardware changes</strong></li>
  <li>coordinated across all OS subsystems</li>
  <li>globally removes redundant copies</li>
  <li>hybrid AVX+DMA scheduling</li>
  <li>safe, correct, dependency-aware</li>
</ul>

<hr />

<h1 id="7-key-takeaways-for-systems-engineers--db-developers">7. Key Takeaways for Systems Engineers &amp; DB Developers</h1>

<h3 id="1-treat-data-movement-as-a-first-class-resource"><strong>1. Treat data movement as a first-class resource</strong></h3>
<p>Most high-performance systems are bottlenecked not by compute, but <strong>by copy</strong>.</p>

<h3 id="2-enable-asynchronous-batched-segmented-copy"><strong>2. Enable asynchronous, batched, segmented copy</strong></h3>
<p>Databases (LSM-tree compaction, snapshotting, RPC serialization) can all benefit from this.</p>

<h3 id="3-provide-a-copy-service-in-your-system"><strong>3. Provide a copy service in your system</strong></h3>
<p>You can adopt a similar design:</p>

<ul>
  <li>unified copy queue</li>
  <li>async API</li>
  <li>segment descriptors</li>
  <li>dependency tracking</li>
  <li>global optimization rules</li>
</ul>

<h3 id="4-hardware-heterogeneity-should-be-automatically-managed"><strong>4. Hardware heterogeneity should be automatically managed</strong></h3>
<p>Avoid exposing DMA/AVX details to application logic.</p>

<h3 id="5-think-in-terms-of-global-optimization"><strong>5. Think in terms of global optimization</strong></h3>
<p>Redundant copies should be eliminated across system layers.</p>

<hr />

<h1 id="8-how-to-read-this-paper-efficiently">8. How to Read This Paper Efficiently</h1>

<p>A recommended route:</p>

<h3 id="if-you-are-new-to-os-papers"><strong>If you are new to OS papers:</strong></h3>
<ol>
  <li>Abstract</li>
  <li>Introduction &amp; Motivation figures</li>
  <li>Architecture overview</li>
  <li>Evaluation summary</li>
</ol>

<h3 id="if-you-build-databases--rpc--runtimes"><strong>If you build databases / RPC / runtimes:</strong></h3>
<ol>
  <li>API &amp; queue abstractions</li>
  <li>segment-based pipeline</li>
  <li>DMA+AVX piggyback scheduling</li>
  <li>copy absorption mechanism</li>
</ol>

<h3 id="checklist-after-reading"><strong>Checklist after reading</strong></h3>
<p>You should be able to answer:</p>

<ul>
  <li>Why is copy a bottleneck today?</li>
  <li>What does an “OS-level asynchronous copy service” mean?</li>
  <li>How does Copier maintain correctness under async reordering?</li>
  <li>How are DMA and AVX scheduled cooperatively?</li>
  <li>How is global copy absorption possible?</li>
</ul>

<hr />

<h1 id="9-qa-from-sosp-2025-session-discussion">9. Q&amp;A (From SOSP 2025 Session Discussion)</h1>

<h3 id="q1-does-copier-introduce-more-context-switch-overhead"><strong>Q1: Does Copier introduce more context-switch overhead?</strong></h3>
<p><strong>A1:</strong> No. Copier runs as kernel background worker threads using shared queues.<br />
There are <em>no extra context switches</em>.</p>

<hr />

<h3 id="q2-linux-kernel-cannot-freely-use-avx-instructions-why-can-copier"><strong>Q2: Linux kernel cannot freely use AVX instructions. Why can Copier?</strong></h3>
<p><strong>A2:</strong><br />
Copier batches multiple copy tasks and executes them continuously,<br />
avoiding frequent AVX state save/restore.<br />
Thus, it amortizes the cost and remains safe.</p>

<hr />

<h3 id="q3-why-does-copier-increase-power-consumption"><strong>Q3: Why does Copier increase power consumption?</strong></h3>
<p><strong>A3:</strong><br />
Copier uses polling threads to minimize submission overhead.<br />
This improves throughput but increases energy usage.<br />
The authors optimized polling via a NAPI-like mechanism to reduce overhead.</p>

<hr />

<h1 id="references">References</h1>
<ul>
  <li>SOSP 2025 Session 13 Papers:<br />
https://zhuanlan.zhihu.com/column/c_1961542888350549465</li>
  <li>ACM DOI: https://dl.acm.org/doi/10.1145/3731569.3764800</li>
</ul>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="paper-notes" /><summary type="html"><![CDATA[A concise overview of Copier, SOSP 2025’s asynchronous OS-level memory copy service.]]></summary></entry><entry><title type="html">CortenMM: Efficient Memory Management with Strong Correctness Guarantees — SOSP 2025 Paper Review</title><link href="https://junhaohu-tech.github.io/paper-notes/understanding-cortenmm/" rel="alternate" type="text/html" title="CortenMM: Efficient Memory Management with Strong Correctness Guarantees — SOSP 2025 Paper Review" /><published>2025-11-15T00:00:00+00:00</published><updated>2025-11-15T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/paper-notes/understanding-cortenmm</id><content type="html" xml:base="https://junhaohu-tech.github.io/paper-notes/understanding-cortenmm/"><![CDATA[<h1 id="-1-overview">🔍 1. Overview</h1>

<p><strong>Paper:</strong> <em>CortenMM: Efficient Memory Management with Strong Correctness Guarantees</em><br />
<strong>Conference:</strong> SOSP 2025<br />
<strong>Authors:</strong> Shanghai Jiao Tong University, Huawei</p>

<p>CortenMM proposes a <strong>new OS memory management architecture</strong> that replaces Linux’s traditional <strong>VMA (Virtual Memory Area)</strong> abstraction with a lightweight, per-page entry model that simplifies correctness, avoids locking bottlenecks, and significantly improves multi-core scalability.</p>

<p>This review follows the same format as the previous <em>Copier</em> analysis and focuses on:</p>

<ul>
  <li>What problem CortenMM solves</li>
  <li>Why existing OS architectures struggle</li>
  <li>How CortenMM achieves correctness + performance</li>
  <li>System architecture &amp; mechanisms</li>
  <li>Evaluation highlights</li>
  <li>Q&amp;A</li>
  <li>Reflections</li>
</ul>

<hr />

<h1 id="-2-background--motivation">🧠 2. Background &amp; Motivation</h1>

<p>Modern OSes (Linux, BSD, etc.) use a <strong>dual-layer memory management model</strong>:</p>

<ol>
  <li><strong>VMA layer (software abstraction)</strong>
    <ul>
      <li>Interval-tree over contiguous virtual memory regions</li>
      <li>Stores permissions, flags, mappings</li>
      <li>Shared among threads of a process</li>
      <li>Requires synchronization</li>
    </ul>
  </li>
  <li><strong>Page Table layer (hardware abstraction)</strong>
    <ul>
      <li>Per-page mapping data used during address translation</li>
      <li>Fine-grained and hierarchical, but opaque to OS-level policies</li>
    </ul>
  </li>
</ol>

<p>This split causes several issues.</p>

<h2 id="-problem-1--vma-is-a-coarse-grained-global-structure">🚧 <strong>Problem 1 — VMA is a coarse-grained global structure</strong></h2>

<p>Even when threads access <em>distinct</em> regions, they might:</p>

<ul>
  <li>Modify or split the same VMA node</li>
  <li>Access the VMA tree protected by <strong>mmap_lock</strong></li>
  <li>Serialize operations that should be independent</li>
</ul>

<p>This becomes a bottleneck for:</p>

<ul>
  <li>Multi-threaded memory allocators</li>
  <li>Large mmap workloads</li>
  <li>JIT compilers</li>
  <li>High-performance runtime systems</li>
  <li>NUMA-aware applications</li>
</ul>

<h2 id="-problem-2--vma--page-table-translation-is-expensive">🚧 <strong>Problem 2 — VMA → Page Table translation is expensive</strong></h2>

<p>Every mmap/munmap / CoW / mprotect / page fault must:</p>

<ul>
  <li>Traverse VMAs</li>
  <li>Then update page tables</li>
  <li>Then flush TLBs</li>
</ul>

<p>The two-layer design adds complexity and latency.</p>

<h2 id="-problem-3--correctness-reasoning-is-hard">🚧 <strong>Problem 3 — Correctness reasoning is hard</strong></h2>

<p>Correctness invariants must be maintained across:</p>

<ul>
  <li>VMA interval tree</li>
  <li>Multi-level page table</li>
  <li>Shared vs private mappings</li>
  <li>CoW and permissions</li>
  <li>Kernel vs user operations</li>
</ul>

<p>CortenMM’s insight:</p>

<blockquote>
  <p><strong>What if we eliminate the VMA layer entirely and make per-PTE metadata the only authoritative source of memory mappings?</strong></p>
</blockquote>

<hr />

<h1 id="️-3-cortenmm-architecture">🏗️ 3. CortenMM Architecture</h1>

<p>CortenMM introduces <strong>a unified memory management model</strong> based entirely on:</p>

<ul>
  <li>Per-page metadata</li>
  <li>Directly associated with PTE structure</li>
  <li>Without VMA</li>
  <li>Fully concurrent</li>
  <li>Lock-light or lock-free</li>
  <li>Formally verified correctness properties</li>
</ul>

<hr />

<h1 id="-4-key-concepts--mechanisms">🔑 4. Key Concepts &amp; Mechanisms</h1>

<h2 id="41-per-pte-metadata-the-heart-of-cortenmm">4.1 Per-PTE Metadata (The Heart of CortenMM)</h2>

<p>Instead of storing mapping properties in large VMAs, CortenMM adds:</p>

<ul>
  <li>Small (8-byte) metadata per PTE</li>
  <li>Allocated <em>on demand</em></li>
  <li>Aligned with page table entries</li>
  <li>No memory overhead for unmapped regions</li>
  <li>Enables constant-time lookup</li>
</ul>

<p>Each PTE holds:</p>

<ul>
  <li>permissions</li>
  <li>sharing type</li>
  <li>flags for operations</li>
  <li>versioning for concurrency</li>
  <li>state transitions</li>
</ul>

<p>This <strong>collapses VMA and page table into a single layer</strong>, improving both simplicity and performance.</p>

<hr />

<h2 id="42-interval-skiplist-for-fast-range-operations">4.2 Interval Skiplist for Fast Range Operations</h2>

<p>Since VMAs are gone, the system still needs to support range-based operations such as:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">mmap</code></li>
  <li><code class="language-plaintext highlighter-rouge">munmap</code></li>
  <li><code class="language-plaintext highlighter-rouge">mprotect</code></li>
  <li>CoW initialization</li>
  <li>range invalidations</li>
</ul>

<p>CortenMM uses a <strong>Concurrent Interval Skiplist</strong>, enabling:</p>

<ul>
  <li>true parallel operations</li>
  <li>range splitting and merging</li>
  <li>O(log n) insertion and lookup</li>
  <li>no global locks</li>
  <li>scalable on multicore systems</li>
</ul>

<hr />

<h2 id="43-strong-correctness-properties">4.3 Strong Correctness Properties</h2>

<p>The new model simplifies reasoning:</p>

<ul>
  <li>Every byte of virtual memory is covered by exactly one metadata entry</li>
  <li>No overlapping intervals</li>
  <li>Permission invariants enforced per page</li>
  <li>Proof-friendly design</li>
</ul>

<p>The paper includes a formal model ensuring correctness for:</p>

<ul>
  <li>page faults</li>
  <li>TLB shootdowns</li>
  <li>concurrent operations</li>
  <li>flag updates</li>
  <li>resource reclamation</li>
</ul>

<hr />

<h1 id="️-5-multi-core-scalability-improvements">⚙️ 5. Multi-Core Scalability Improvements</h1>

<p>CortenMM eliminates the classic <strong>mmap_lock bottleneck</strong>.</p>

<h3 id="how-linux-behaves-today">How Linux behaves today:</h3>
<ul>
  <li>Multiple threads calling mmap/munmap → forced into global lock contention</li>
  <li>Even disjoint memory regions require synchronization</li>
  <li>VMA tree operations scale poorly beyond 4–8 cores</li>
</ul>

<h3 id="how-cortenmm-changes-the-game">How CortenMM changes the game:</h3>
<ul>
  <li>No VMA tree → no global lock</li>
  <li>Page-level metadata → only fine-grained locks</li>
  <li>Per-range operations use skiplist with local synchronization</li>
  <li>On multi-core (up to 64 cores), throughput grows nearly linearly</li>
</ul>

<hr />

<h1 id="-6-evaluation-highlights">📊 6. Evaluation Highlights</h1>

<p>Measured against Linux:</p>

<table>
  <thead>
    <tr>
      <th>Workload</th>
      <th>Improvement</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>mmap-heavy multithread apps</td>
      <td><strong>3.3× – 11.6× faster</strong></td>
    </tr>
    <tr>
      <td>page-fault intensive workloads</td>
      <td><strong>2× – 5× faster</strong></td>
    </tr>
    <tr>
      <td>memory allocators (e.g., tcmalloc)</td>
      <td><strong>20% – 60% faster</strong></td>
    </tr>
    <tr>
      <td>JIT workloads</td>
      <td>major latency reductions</td>
    </tr>
    <tr>
      <td>general MMLRU / VM subsystem</td>
      <td>significantly more parallel</td>
    </tr>
  </tbody>
</table>

<p>Memory overhead:</p>

<ul>
  <li>On-demand metadata → <strong>&lt;2% overhead</strong></li>
  <li>Worst-case theoretical: ~2×</li>
  <li>Real workloads: near Linux baseline</li>
</ul>

<hr />

<h1 id="-7-qa-from-sosp-discussion--public-commentary">💬 7. Q&amp;A (from SOSP discussion &amp; public commentary)</h1>

<h3 id="q1-does-per-pte-metadata-significantly-increase-memory-usage"><strong>Q1: Does per-PTE metadata significantly increase memory usage?</strong></h3>

<p><strong>A1:</strong> No.<br />
Metadata is allocated <strong>only for mapped pages</strong>.</p>

<ul>
  <li>Real workloads: <strong>&lt;2% overhead</strong></li>
  <li>Worst case: 2× (but almost never happens)</li>
  <li>Future optimization: use unused bits in PTE to shrink size further</li>
</ul>

<hr />

<h3 id="q2-must-the-metadata-be-stored-contiguously"><strong>Q2: Must the metadata be stored contiguously?</strong></h3>

<p><strong>A2:</strong> Logically yes, physically irrelevant.</p>

<p>The metadata array aligns with page table pages for easy indexing.<br />
Each entry is only <strong>8 bytes</strong>, so the physical requirement poses minimal overhead.</p>

<hr />

<h3 id="q3-why-does-linux-scale-poorly-with-many-cores-in-tests"><strong>Q3: Why does Linux scale poorly with many cores in tests?</strong></h3>

<p><strong>A3:</strong> Because Linux still relies on the global <strong>VMA tree</strong>, protected by <strong>mmap_lock</strong>.</p>

<p>Even when threads operate on unrelated memory areas, they may need to:</p>

<ul>
  <li>split the same VMA</li>
  <li>modify flags</li>
  <li>traverse shared tree nodes</li>
</ul>

<p>This unnecessary synchronization is the main source of poor scalability.</p>

<hr />

<h1 id="-8-reflection--takeaways">🧭 8. Reflection &amp; Takeaways</h1>

<h3 id="-1-the-vma-abstraction-is-outdated-for-modern-multicore-systems">🔹 <strong>1. The VMA abstraction is outdated for modern multicore systems</strong></h3>
<p>CortenMM shows that coarse-grained VMAs introduce:</p>

<ul>
  <li>software complexity</li>
  <li>unnecessary global synchronization</li>
  <li>correctness pitfalls</li>
</ul>

<p>Eliminating VMAs simplifies both design and verification.</p>

<h3 id="-2-page-level-metadata-is-a-powerful-unifying-abstraction">🔹 <strong>2. Page-level metadata is a powerful unifying abstraction</strong></h3>
<p>A single-layer model:</p>

<ul>
  <li>makes correctness properties more obvious</li>
  <li>removes costly translations</li>
  <li>matches hardware semantics more closely</li>
</ul>

<p>It is “closer to the metal.”</p>

<h3 id="-3-os-scalability-problems-often-stem-from-old-abstractions">🔹 <strong>3. OS scalability problems often stem from old abstractions</strong></h3>
<p>The paper follows a common theme seen in modern OS research:</p>

<blockquote>
  <p>Remove legacy abstractions → Make fine-grained state the first-class entity.</p>
</blockquote>

<p>Like Dune, Arrakis, FlexSC, and now Copier (previous review), CortenMM rethinks long-standing OS interfaces.</p>

<h3 id="-4-a-promising-direction-for-next-generation-os-memory-systems">🔹 <strong>4. A promising direction for next-generation OS memory systems</strong></h3>
<p>CortenMM resembles the shift toward:</p>

<ul>
  <li>per-object metadata</li>
  <li>verifiable OS designs</li>
  <li>concurrency-friendly structures</li>
  <li>hardware-level alignment</li>
</ul>

<p>The design philosophy could influence:</p>

<ul>
  <li>microkernels</li>
  <li>unikernels</li>
  <li>confidential computing VMMs</li>
  <li>high-performance cloud runtimes</li>
</ul>

<hr />

<h1 id="-9-summary">📌 9. Summary</h1>

<p>CortenMM re-architects OS memory management by:</p>

<ul>
  <li>Removing VMAs</li>
  <li>Using per-PTE metadata</li>
  <li>Introducing a concurrent interval skiplist</li>
  <li>Ensuring provable correctness</li>
  <li>Achieving excellent multi-core scalability</li>
</ul>

<p>It is one of the most impactful VM subsystem papers in recent years and suggests a future where OSes abandon coarse, process-wide abstractions in favor of per-page, concurrent, verifiable designs.</p>

<h1 id="references">References</h1>
<ul>
  <li>SOSP 2025 Session 13 Papers:<br />
https://zhuanlan.zhihu.com/column/c_1961542888350549465</li>
  <li>ACM DOI: https://dl.acm.org/doi/10.1145/3731569.3764836</li>
</ul>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="paper-notes" /><summary type="html"><![CDATA[A review of CortenMM, a new OS memory manager that eliminates VMA bottlenecks and enables scalable, provably correct memory operations.]]></summary></entry><entry><title type="html">Fifth Alibaba Middleware Performance Challenge — Analysis</title><link href="https://junhaohu-tech.github.io/competitions/competition-fifth-alibaba-middleware-performance-challenge/" rel="alternate" type="text/html" title="Fifth Alibaba Middleware Performance Challenge — Analysis" /><published>2025-11-14T00:00:00+00:00</published><updated>2025-11-14T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/competitions/competition-fifth-alibaba-middleware-performance-challenge</id><content type="html" xml:base="https://junhaohu-tech.github.io/competitions/competition-fifth-alibaba-middleware-performance-challenge/"><![CDATA[<h1 id="-fifth-alibaba-middleware-performance-challenge">🏆 Fifth Alibaba Middleware Performance Challenge</h1>
<p>A concise analysis of the 5th Alibaba Middleware Performance Challenge, covering the adaptive load-balancing task in the preliminary round and the in-process message storage engine in the final round.<br />
This article highlights core algorithms, system design trade-offs, and the practical engineering lessons learned from solving real-world middleware problems.</p>

<h1 id="1-competition-overview">1. Competition Overview</h1>

<p><strong>Competition:</strong> Fifth Alibaba Middleware Performance Challenge<br />
<strong>Organizer:</strong> Alibaba Cloud / Tianchi Platform<br />
<strong>Official Page:</strong> https://tianchi.aliyun.com/competition/entrance/231714</p>

<p>The Alibaba Middleware Performance Challenge is a hands-on, engineering-intensive competition designed to simulate the realities of large-scale distributed middleware systems.<br />
Instead of algorithms or puzzles, this competition evaluates:</p>

<ul>
  <li>high-performance system design</li>
  <li>load balancing</li>
  <li>correctness under concurrency</li>
  <li>throughput / latency optimization</li>
  <li>overload control</li>
  <li>storage engine implementation</li>
</ul>

<p>Participants compete in two stages:</p>

<ol>
  <li><strong>Preliminary Round — Adaptive Load Balancing</strong></li>
  <li><strong>Final Round — Queue-based Message Storage Engine</strong></li>
</ol>

<p>Both reflect real internal challenges faced inside Alibaba’s infrastructure.</p>

<hr />

<h1 id="2-preliminary-round--adaptive-load-balancing">2. Preliminary Round — Adaptive Load Balancing</h1>

<p><strong>Challenge Page:</strong><br />
https://code.aliyun.com/middlewarerace2019/adaptive-loadbalance</p>

<p><strong>Task:</strong> Implement a self-adaptive load balancing algorithm that automatically adapts to fluctuating provider capacity, minimizes response latency, and maximizes throughput.</p>

<p>Providers’ service capability fluctuates dynamically.<br />
The system must avoid overload, starvation, and collapse.</p>

<hr />

<h2 id="21-requirements">2.1 Requirements</h2>

<h3 id="gateway-responsibilities">Gateway Responsibilities</h3>
<ul>
  <li>dynamically distribute traffic based on real-time backend performance</li>
  <li>minimize RTT, maximize TPS</li>
  <li>reject excessive traffic when the system is overloaded</li>
</ul>

<h3 id="provider-responsibilities">Provider Responsibilities</h3>
<ul>
  <li>evaluate its own processing capacity</li>
  <li>reject requests when overloaded</li>
  <li>protect its latency and stability</li>
</ul>

<h3 id="system-level-behavior">System-level Behavior</h3>
<p>If <strong>incoming request rate &gt; global capacity</strong>,<br />
the <strong>Gateway must proactively reject</strong> requests (global backpressure).</p>

<hr />

<h2 id="22-evaluation-procedure">2.2 Evaluation Procedure</h2>

<p>PTS (Performance Testing Service) sends HTTP requests: 
PTS → Gateway → Provider → Response</p>

<p>Provider capacity changes across:</p>

<ul>
  <li>overload</li>
  <li>equilibrium</li>
  <li>normal</li>
  <li>partial degradation</li>
</ul>

<p>Performance Metrics:</p>
<ul>
  <li><strong>Success Requests</strong> (primary metric)</li>
  <li><strong>Max TPS</strong> (tie-breaker)</li>
  <li>1024 concurrent connections</li>
  <li>1-minute formal test</li>
</ul>

<hr />

<h1 id="3-preliminary-round--full-technical-analysis">3. Preliminary Round — Full Technical Analysis</h1>

<p>This round is a true systems problem involving stability, noisy feedback, and dynamic latency behavior.<br />
We analyze it from three perspectives.</p>

<hr />

<h2 id="31-professor--research-perspective">3.1 Professor / Research Perspective</h2>

<p>This task is mathematically a <strong>feedback control problem</strong> where:</p>

<ul>
  <li>provider service rates μ(t) are time-varying</li>
  <li>latency L(t) is a delayed/noisy signal</li>
  <li>naive greedy strategies oscillate and collapse</li>
</ul>

<p>Key principles required:</p>

<ul>
  <li>EWMA smoothing to filter noisy latency</li>
  <li>penalty mechanisms to avoid oscillation</li>
  <li>global overload control</li>
  <li>stability in feedback loops</li>
  <li>routing strategies that avoid deterministic oscillation</li>
</ul>

<p>The problem structurally mirrors:</p>

<ul>
  <li>congestion control</li>
  <li>queueing systems</li>
  <li>control theory</li>
  <li>distributed service schedulers</li>
</ul>

<hr />

<h2 id="32-systems-engineer-perspective">3.2 Systems Engineer Perspective</h2>

<p>Production-grade load balancers must handle:</p>

<ul>
  <li>jitter</li>
  <li>nonlinear performance</li>
  <li>sudden overload</li>
  <li>partial failures</li>
  <li>noisy measurements</li>
  <li>need for early rejection</li>
</ul>

<p>The competition intentionally simulates these real-world issues.</p>

<p>Key engineering behaviors:</p>

<h3 id="a-latency-is-the-earliest-most-reliable-signal">A. Latency is the earliest, most reliable signal</h3>
<p>Latency increases before throughput drops → ideal for early detection.</p>

<h3 id="b-penalizing-slow-providers-prevents-oscillation">B. Penalizing slow providers prevents oscillation</h3>
<p>Immediate switching → thrashing → collapse.</p>

<h3 id="c-global-overload-rejection-is-mandatory">C. Global overload rejection is mandatory</h3>
<p>This mirrors circuit breaking in Envoy, Nginx, Kafka, etc.</p>

<h3 id="d-provider-must-protect-itself">D. Provider must protect itself</h3>
<p>Reject requests if overloaded to preserve SLA.</p>

<hr />

<h2 id="33-contestant-perspective">3.3 Contestant Perspective</h2>

<p>Common Wrong Strategies:</p>

<ul>
  <li>static weights</li>
  <li>round-robin</li>
  <li>greedy lowest-latency</li>
  <li>no global rejection</li>
  <li>hard switching without smoothing</li>
</ul>

<p>Winning strategies:</p>

<ul>
  <li>latency smoothing</li>
  <li>penalty-based stability</li>
  <li>capacity estimation</li>
  <li>weighted random routing</li>
  <li>global load shedding</li>
</ul>

<hr />

<h1 id="-34-high-scoring-algorithm-architecture-core-formulas">⭐ <strong>3.4 High-Scoring Algorithm Architecture (Core Formulas)</strong></h1>

<p>The following is the distilled architecture used by top-ranking teams and widely adopted in real-world distributed systems.</p>

<hr />

<h2 id="1-provider-scoring-function"><strong>1. Provider Scoring Function</strong></h2>

<p>Each provider is assigned a real-time score:
score_i = EWMA(latency_i) + penalty_i + failure_rate_factor</p>

<ul>
  <li><strong>EWMA latency</strong> smooths noise</li>
  <li><strong>penalty</strong> discourages routing to recently slow nodes</li>
  <li><strong>failure rate factor</strong> penalizes timeouts or rejections</li>
</ul>

<p>Lower score = better provider.</p>

<hr />

<h2 id="2-provider-capacity-estimation"><strong>2. Provider Capacity Estimation</strong></h2>

<p>Real-time capacity predicted as:
estimated_capacity_i = k / EWMA(latency_i)</p>

<p>This approximates each provider’s μ(t).<br />
Lower latency → more remaining capacity.</p>

<hr />

<h2 id="3-global-overload-protection"><strong>3. Global Overload Protection</strong></h2>

<p>Before routing a new request:
if incoming_rate &gt; Σ estimated_capacity_i:
shed requests</p>

<p>This prevents catastrophic collapse<br />
and reflects real-world backpressure mechanisms.</p>

<hr />

<h2 id="4-routing-decision-weighted-random"><strong>4. Routing Decision (Weighted Random)</strong></h2>

<p>Providers are selected probabilistically:</p>

<ul>
  <li>lower score → higher probability</li>
  <li>avoids deterministic oscillation</li>
  <li>stabilizes routing behavior</li>
</ul>

<hr />

<h2 id="5-penalty-decay"><strong>5. Penalty Decay</strong></h2>

<p>Penalties gradually decay:
penalty_i = penalty_i * 0.9</p>

<p>Recovered providers should return gradually to rotation.</p>

<hr />

<h1 id="35-community-write-ups--study-notes">3.5 Community Write-ups &amp; Study Notes</h1>

<p>These two excellent resources help deepen understanding:</p>

<h3 id="practical-walkthrough">Practical Walkthrough</h3>
<p>https://tianchi.aliyun.com/notebook/66591</p>

<h3 id="detailed-strategy-notes">Detailed Strategy Notes</h3>
<p>https://tianchi.aliyun.com/notebook/60036</p>

<p>They cover routing instability, latency behavior, workload patterns, and tuning strategies.</p>

<hr />

<h1 id="4-final-round--queue-based-message-storage-engine">4. Final Round — Queue-Based Message Storage Engine</h1>

<p><strong>Challenge Page:</strong><br />
https://code.aliyun.com/middlewarerace2019/mqrace2019</p>

<p><strong>Task:</strong> Implement a persistent in-process message store supporting:</p>

<ul>
  <li>append</li>
  <li>time-window queries</li>
  <li>time-window aggregation (sum/avg on field <code class="language-plaintext highlighter-rouge">a</code>)</li>
</ul>

<p>This problem is a scaled-down version of RocketMQ / Kafka log storage.</p>

<hr />

<h2 id="41-requirements">4.1 Requirements</h2>

<ul>
  <li>message format: <code class="language-plaintext highlighter-rouge">{a: int, t: timestamp}</code></li>
  <li>query <code class="language-plaintext highlighter-rouge">(t1, t2)</code></li>
  <li>support sum/avg in the same window</li>
  <li>fully custom data layout allowed</li>
</ul>

<p>This is essentially a small <strong>time-series database</strong> problem.</p>

<hr />

<h1 id="42-technical-analysis--academic-view">4.2 Technical Analysis — Academic View</h1>

<p>Conceptually involves:</p>

<ul>
  <li>append-only log storage</li>
  <li>timestamp-ordered indexing</li>
  <li>prefix-sum acceleration</li>
  <li>LSM-tree style layout</li>
  <li>selective scanning via metadata</li>
</ul>

<hr />

<h1 id="43-technical-analysis--systems-engineer-view">4.3 Technical Analysis — Systems Engineer View</h1>

<p>Key design components:</p>

<h3 id="a-log-segment-format">A. Log Segment Format</h3>
<p>[header][entries][metadata]</p>

<h3 id="b-indexing">B. Indexing</h3>
<ul>
  <li>segment-level min/max timestamps</li>
  <li>per-entry or per-block timestamp arrays</li>
  <li>binary search</li>
</ul>

<h3 id="c-query-execution">C. Query Execution</h3>
<ol>
  <li>find relevant segments</li>
  <li>binary search for boundaries</li>
  <li>scan subset</li>
  <li>compute sum/avg via prefix sums</li>
</ol>

<h3 id="d-durability--efficiency">D. Durability &amp; Efficiency</h3>
<ul>
  <li>buffered writes vs fsync</li>
  <li>mmap</li>
  <li>contiguous memory layout</li>
</ul>

<hr />

<h1 id="44-community-write-ups--winner-architectures">4.4 Community Write-ups &amp; Winner Architectures</h1>

<h3 id="-champion-solution">🥇 Champion Solution</h3>
<p>https://tianchi.aliyun.com/notebook/77159</p>

<p>Highlights:</p>
<ul>
  <li>multi-level segments</li>
  <li>prefix sums</li>
  <li>binary search + optimized scan</li>
  <li>near zero-per-entry overhead</li>
</ul>

<hr />

<h3 id="-runner-up-solution">🥈 Runner-up Solution</h3>
<p>https://tianchi.aliyun.com/forum/post/77949</p>

<p>Highlights:</p>
<ul>
  <li>vector-based design</li>
  <li>batch writing</li>
  <li>clean binary search</li>
</ul>

<hr />

<h3 id="-third-place-solution">🥉 Third Place Solution</h3>
<p>https://tianchi.aliyun.com/notebook/77274</p>

<p>Highlights:</p>
<ul>
  <li>dynamic segment splitting</li>
  <li>timestamp-indexed arrays</li>
  <li>simple, effective design</li>
</ul>

<hr />

<h1 id="45-comparison-of-top-solutions">4.5 Comparison of Top Solutions</h1>

<table>
  <thead>
    <tr>
      <th>Aspect</th>
      <th>Champion</th>
      <th>Runner-up</th>
      <th>Third Place</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Write Path</td>
      <td>Most optimized</td>
      <td>Stable batch</td>
      <td>Straightforward</td>
    </tr>
    <tr>
      <td>Query Engine</td>
      <td>Prefix sums + binary search</td>
      <td>Binary search</td>
      <td>Linear scan</td>
    </tr>
    <tr>
      <td>Indexing</td>
      <td>Multi-level</td>
      <td>Minimal</td>
      <td>Lightweight</td>
    </tr>
    <tr>
      <td>Durability</td>
      <td>Tuned</td>
      <td>Balanced</td>
      <td>Simple</td>
    </tr>
    <tr>
      <td>Complexity</td>
      <td>High</td>
      <td>Medium</td>
      <td>Low</td>
    </tr>
  </tbody>
</table>

<hr />

<h1 id="5-reflection--conclusion">5. Reflection &amp; Conclusion</h1>

<p>This competition is an outstanding demonstration of <em>real systems engineering</em>, covering:</p>

<h3 id="from-the-preliminary-round"><strong>From the Preliminary Round:</strong></h3>
<ul>
  <li>feedback control in distributed systems</li>
  <li>adaptive load balancing</li>
  <li>oscillation prevention</li>
  <li>global backpressure</li>
  <li>EWMA &amp; penalty mechanisms</li>
  <li>dynamic capacity estimation</li>
</ul>

<h3 id="from-the-final-round"><strong>From the Final Round:</strong></h3>
<ul>
  <li>log-structured storage design</li>
  <li>timestamp indexing</li>
  <li>streaming/analytical workloads</li>
  <li>prefix-sum based acceleration</li>
  <li>memory layout optimization</li>
  <li>file segmenting &amp; metadata design</li>
</ul>

<hr />

<h2 id="overall-reflection">Overall Reflection</h2>

<p>The competition simulates real challenges encountered in:</p>

<ul>
  <li>distributed systems</li>
  <li>high-performance middleware</li>
  <li>storage engines</li>
  <li>database internals</li>
</ul>

<p>It trains participants to:</p>

<ul>
  <li>reason about system behavior</li>
  <li>design under uncertainty</li>
  <li>balance trade-offs</li>
  <li>engineer performant low-level components</li>
</ul>

<p>For anyone pursuing:</p>

<ul>
  <li>a PhD in Systems / Databases / OS</li>
  <li>a career in distributed infrastructure</li>
  <li>storage engine engineering</li>
  <li>performance optimization</li>
</ul>

<p><strong>this competition provides exceptional preparation and demonstrable technical depth.</strong></p>

<hr />

<h1 id="6-references">6. References</h1>

<ul>
  <li>
    <p>Adaptive Load Balancer Repo<br />
https://code.aliyun.com/middlewarerace2019/adaptive-loadbalance</p>
  </li>
  <li>
    <p>Message Storage Engine Repo<br />
https://code.aliyun.com/middlewarerace2019/mqrace2019</p>
  </li>
  <li>
    <p>Preliminary Round Notes<br />
https://tianchi.aliyun.com/notebook/66591<br />
https://tianchi.aliyun.com/notebook/60036</p>
  </li>
  <li>
    <p>Final Round Winner Write-ups<br />
Champion: https://tianchi.aliyun.com/notebook/77159<br />
Runner-up: https://tianchi.aliyun.com/forum/post/77949<br />
Third Place: https://tianchi.aliyun.com/notebook/77274</p>
  </li>
</ul>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="competitions" /><summary type="html"><![CDATA[A deep-dive analysis of the 5th Alibaba Middleware Performance Challenge, including problem structure, system-level constraints, performance metrics, and architectural implications for distributed middleware systems.]]></summary></entry><entry><title type="html">OceanBase Database Competition (3rd Edition) — Analysis</title><link href="https://junhaohu-tech.github.io/competitions/competition-oceanbase-miniob-database/" rel="alternate" type="text/html" title="OceanBase Database Competition (3rd Edition) — Analysis" /><published>2025-11-12T00:00:00+00:00</published><updated>2025-11-12T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/competitions/competition-oceanbase-miniob-database</id><content type="html" xml:base="https://junhaohu-tech.github.io/competitions/competition-oceanbase-miniob-database/"><![CDATA[<h1 id="-oceanbase-database-competition-3rd-edition">🏆 OceanBase Database Competition (3rd Edition)</h1>

<p>This article analyzes the OceanBase Database competition, a hands-on challenge that requires participants to build a miniature relational database from scratch. Unlike typical coding contests, this competition focuses on core DBMS architecture — including SQL parsing, execution, storage, and indexing.</p>

<hr />

<h1 id="1-competition-overview">1. Competition Overview</h1>

<p><strong>Competition:</strong> OceanBase Database Competition (3rd Edition)<br />
<strong>Official page:</strong> https://open.oceanbase.com/competition</p>

<p>The OceanBase Database Competition is part of the <strong>National Collegiate Computer System Ability Challenge</strong>, a nationwide contest for university students in China.<br />
It is jointly organized by the System Capability Training Expert Group, the National Computer Education Research Association, and leading universities, and hosted by OceanBase.</p>

<p>The competition aims to promote <strong>technical excellence</strong> in data-intensive systems and to bridge the gap between academic concepts and real-world distributed database engineering. Students compete in teams of <strong>1–3 members</strong>, and previous top-20 finalists cannot re-enter to ensure fairness.</p>

<p>The competition consists of <strong>two stages</strong>:</p>

<ol>
  <li><strong>Preliminary Round — MiniOB (a teaching-oriented relational database)</strong></li>
  <li><strong>Final Round — OceanBase (a production-grade distributed SQL database)</strong></li>
</ol>

<hr />

<h1 id="2-preliminary-round--miniob">2. Preliminary Round — MiniOB</h1>

<p>The preliminary stage is built on <strong>MiniOB</strong>, a lightweight relational database engine designed for teaching DBMS fundamentals. It exposes essential components—SQL parsing, planning, execution, storage, and indexing—allowing contestants to extend real database internals.</p>

<hr />

<h2 id="21-official-overview">2.1 Official Overview</h2>

<p>The organizers provide a list of MiniOB tasks here:<br />
https://oceanbase.github.io/miniob/game/miniob_topics/</p>

<p>Topics include:</p>

<ul>
  <li>SQL parsing (SELECT / INSERT / UPDATE / DELETE)</li>
  <li>expression evaluation</li>
  <li>metadata and catalog management</li>
  <li>slotted-page layout</li>
  <li>heap file implementation</li>
  <li>B+ Tree indexing</li>
  <li>iterator-based execution operators</li>
</ul>

<p>These tasks gradually guide contestants <strong>from zero experience to implementing DBMS kernel modules</strong>.</p>

<p><strong>Reference implementation:</strong> https://github.com/S-1-T/miniob</p>

<hr />

<h2 id="22-technical-analysis-of-the-preliminary-round">2.2 Technical Analysis of the Preliminary Round</h2>

<h3 id="1-system-architecture-and-sql-pipeline">1. System Architecture and SQL Pipeline</h3>

<p>A SQL query flows through:</p>

<ol>
  <li>Parsing (Flex/Bison)</li>
  <li>Logical planning</li>
  <li>Physical planning</li>
  <li>Execution using a Volcano iterator model</li>
  <li>Storage engine (heap files + B+ Tree indexing)</li>
  <li>SEDA-based request scheduling</li>
</ol>

<p>MiniOB mirrors real RDBMS architecture while remaining small enough for students to extend.</p>

<hr />

<h3 id="2-seda-architecture">2. SEDA Architecture</h3>

<p>MiniOB uses a <strong>staged event-driven architecture (SEDA)</strong>:</p>

<ul>
  <li>each stage has its own thread pool</li>
  <li>events move through stages asynchronously</li>
  <li><code class="language-plaintext highlighter-rouge">done()</code> signals event completion</li>
</ul>

<p>This teaches non-blocking concurrency and modular performance design.</p>

<hr />

<h3 id="3-engineering-challenges">3. Engineering Challenges</h3>

<h4 id="-sql-parser--error-handling">• SQL Parser &amp; Error Handling</h4>
<p>Distinguishing syntax errors from semantic errors, performing metadata validation, and returning correct error codes is essential.</p>

<h4 id="-metadata-management">• Metadata Management</h4>
<p>Operations like <code class="language-plaintext highlighter-rouge">DROP TABLE</code> reveal the importance of catalog consistency and error propagation.</p>

<h4 id="-extending-the-type-system">• Extending the Type System</h4>
<p>Example: Adding a native <code class="language-plaintext highlighter-rouge">DATE</code> type requires modifying lexing, grammar, type checking, predicate evaluation, and storage.</p>

<h4 id="-index-behavior">• Index Behavior</h4>
<p>B+ Tree split logic, parent pointer updates, and page invariants must be correct to avoid silent corruption.</p>

<hr />

<h3 id="4-debugging-lessons">4. Debugging Lessons</h3>

<p>Common pitfalls include:</p>

<ul>
  <li>missing <code class="language-plaintext highlighter-rouge">break</code> statements</li>
  <li>incorrect use of <code class="language-plaintext highlighter-rouge">%s</code>/<code class="language-plaintext highlighter-rouge">std::string</code></li>
  <li>metadata inconsistencies causing silent errors</li>
  <li>SEDA events not calling <code class="language-plaintext highlighter-rouge">done()</code></li>
  <li>incorrect block layouts in indexes</li>
</ul>

<p>Debugging MiniOB teaches students how subsystems interact and how bugs propagate across the engine.</p>

<hr />

<h3 id="5-skills-gained">5. Skills Gained</h3>

<ul>
  <li>understanding DBMS architecture beyond textbooks</li>
  <li>navigating unfamiliar codebases</li>
  <li>enforcing storage and metadata invariants</li>
  <li>debugging multicomponent systems</li>
  <li>reasoning about correctness vs performance</li>
</ul>

<hr />

<h2 id="23-recommended-development-notes">2.3 Recommended Development Notes</h2>

<p>For readers who want a more narrative, step-by-step view of working with MiniOB, I highly recommend a four-part development diary written by Zheng Jinghong (郑璟泓). The series follows one student’s journey through the 2021 OceanBase Database Competition preliminary round and is very close to what a real beginner-to-intermediate MiniOB path looks like.</p>

<ul>
  <li><strong>Part 1 – Environment &amp; Framework</strong></li>
  <li>
    <p>https://deepz.cc/2021/10/miniob-1/
Covers setting up the development environment, cloning the official MiniOB repository, using VS Code with Remote SSH, and getting a high-level understanding of the MiniOB architecture and the “must-do” preliminary problems.</p>
  </li>
  <li><strong>Part 2 – SEDA Architecture</strong></li>
  <li>
    <p>https://deepz.cc/2021/10/miniob-2/
Explains how MiniOB uses a staged event-driven architecture (SEDA): requests are split into stages, each with its own thread pool and event queue, and each event must call <code class="language-plaintext highlighter-rouge">done()</code> when a stage finishes processing it. This is a great way to learn how MiniOB structures its request pipeline beyond a simple thread-per-connection model.</p>
  </li>
  <li><strong>Part 3 – Metadata Validation &amp; Error Handling</strong></li>
  <li>
    <p>https://deepz.cc/2021/10/miniod-3/
Focuses on implementing <code class="language-plaintext highlighter-rouge">DROP TABLE</code> correctly, and on adding metadata validation so that querying a dropped or non-existent table returns a proper error instead of silently succeeding. The diary emphasizes that a DBMS must not only run valid queries, but also reject invalid ones with clear failure modes.</p>
  </li>
  <li><strong>Part 4 – Adding a <code class="language-plaintext highlighter-rouge">DATE</code> Type</strong></li>
  <li>https://deepz.cc/2021/10/miniob-4/
Walks through extending MiniOB with a native <code class="language-plaintext highlighter-rouge">DATE</code> type: modifying the lexer and parser, storing <code class="language-plaintext highlighter-rouge">YYYY-MM-DD</code>, validating date strings, handling <code class="language-plaintext highlighter-rouge">WHERE</code> conditions on dates, and debugging subtle issues (such as using <code class="language-plaintext highlighter-rouge">%s</code> with <code class="language-plaintext highlighter-rouge">std::string</code> and a missing <code class="language-plaintext highlighter-rouge">break</code> in a switch). This part captures the “real feel” of database kernel development.</li>
</ul>

<p>These diaries complement this write-up: while this article focuses on the system-level structure of MiniOB, the diary shows what it is like to work through the competition tasks in practice—debugging, reading code, and gradually building confidence in database internals.</p>

<hr />

<h1 id="3-final-round--oceanbase">3. Final Round — OceanBase</h1>

<p>The final round transitions from MiniOB to <strong>OceanBase</strong>, a distributed SQL database used in production at large financial institutions.</p>

<p>Contestants must design and implement a <strong>bypass import (direct path load)</strong> pipeline.</p>

<hr />
<h2 id="31-official-overview-of-the-final-round">3.1 Official Overview of the Final Round</h2>

<p>The final round transitions from the teaching-oriented MiniOB system to the <strong>enterprise-grade distributed SQL database</strong> OceanBase.<br />
Instead of extending a small relational engine, contestants work with real storage components and system-level APIs to implement a <strong>bypass import (direct path load)</strong> mechanism.</p>

<h3 id="problem-background">Problem Background</h3>

<p>OceanBase’s existing data import path relies on converting input text into large batches of <code class="language-plaintext highlighter-rouge">INSERT</code> statements. These statements must pass through:</p>

<ul>
  <li>SQL parsing</li>
  <li>semantic analysis</li>
  <li>transaction management</li>
  <li>logging</li>
  <li>compaction triggers</li>
</ul>

<p>This results in a long execution path and limited import throughput.</p>

<p>Traditional DBMSs (e.g., Oracle, DB2) provide a “direct path load,” bypassing SQL and transactions and writing directly into <strong>SSTable</strong> storage files. OceanBase does not yet have this feature.</p>

<h3 id="final-round-challenge">Final Round Challenge</h3>

<p>Contestants must design and implement a <strong>high-performance bypass load pipeline</strong> that:</p>

<ol>
  <li>Parses CSV files</li>
  <li>Converts rows into internal OceanBase data formats</li>
  <li>Writes data directly into SSTable blocks</li>
  <li>Achieves large performance improvements over batch INSERT</li>
  <li>Maintains correctness and storage invariants</li>
</ol>

<p>This requires deep understanding of OceanBase internals, distributed storage principles, and high-throughput data ingestion.</p>

<p>References:</p>
<ul>
  <li>https://zhuanlan.zhihu.com/p/617520132</li>
  <li>https://zhuanlan.zhihu.com/p/677020265</li>
  <li>https://open.oceanbase.com/blog/2325423616</li>
</ul>

<hr />

<h2 id="32-technical-analysis-of-the-final-round">3.2 Technical Analysis of the Final Round</h2>

<p>The final round shifts from “implementing components” to “designing an end-to-end high-performance system.”<br />
Below is the analysis structured similarly to the preliminary round.</p>

<hr />

<h3 id="1-system-architecture-and-data-ingestion-pipeline">1. System Architecture and Data Ingestion Pipeline</h3>

<p>A bypass-import pipeline typically follows this flow:</p>

<ol>
  <li><strong>Input Parsing</strong>
    <ul>
      <li>Read CSV / TSV input</li>
      <li>Validate schema, types, delimiters</li>
      <li>Map columns to table schema</li>
    </ul>
  </li>
  <li><strong>Row Conversion</strong>
    <ul>
      <li>Convert textual rows into OceanBase’s internal row representation</li>
      <li>Perform type casting, null checks, boundary validation</li>
    </ul>
  </li>
  <li><strong>Partition Routing</strong>
    <ul>
      <li>Determine which partition / tablet each row belongs to</li>
      <li>Use partition keys and partition metadata</li>
      <li>Avoid data skew and cross-node traffic</li>
    </ul>
  </li>
  <li><strong>Block Building</strong>
    <ul>
      <li>Accumulate rows into <strong>SSTable blocks / micro-blocks</strong></li>
      <li>Preserve sorting requirements (if any)</li>
      <li>Align data with storage engine’s merge and compaction expectations</li>
    </ul>
  </li>
  <li><strong>Direct SSTable Writing</strong>
    <ul>
      <li>Write macro-blocks to storage files</li>
      <li>Update metadata to expose new data to query engine</li>
      <li>Trigger compaction or rely on background merge</li>
    </ul>
  </li>
  <li><strong>Cluster Coordination</strong>
    <ul>
      <li>Handle replicas, network distribution</li>
      <li>Ensure consistency across multi-replica clusters</li>
    </ul>
  </li>
</ol>

<p>This architecture mimics ingestion pipelines used in distributed warehouses such as ClickHouse, BigQuery, TiDB Lightning, and HDFS bulk loaders.</p>

<p>From a professor’s perspective, this stage demonstrates <strong>systems-level design in a distributed database kernel</strong>.</p>

<hr />

<h3 id="2-core-engineering-challenges">2. Core Engineering Challenges</h3>

<h4 id="-challenge-1--partition-aware-parallelism">• Challenge 1 — Partition-Aware Parallelism</h4>
<p>A large cluster may have dozens or hundreds of partitions.<br />
A high-performance loader must:</p>

<ul>
  <li>detect target partition per row</li>
  <li>group rows by partition</li>
  <li>spawn per-partition worker threads</li>
  <li>avoid cross-partition contention</li>
</ul>

<p><strong>Key insight:</strong><br />
Parallelism is not “one big thread pool,” but <strong>per-partition concurrency</strong> to minimize lock contention and network hops.</p>

<h4 id="-challenge-2--conversion-into-internal-formats">• Challenge 2 — Conversion into Internal Formats</h4>
<p>OceanBase stores rows in tightly packed, serialized structures.<br />
Building these correctly requires:</p>

<ul>
  <li>matching internal type layouts</li>
  <li>nullability checks</li>
  <li>byte-level serialization</li>
  <li>maintaining memory alignment</li>
</ul>

<p>This is a direct test of “reading real-world database code” ability.</p>

<h4 id="-challenge-3--building-sstable-blocks-correctly">• Challenge 3 — Building SSTable Blocks Correctly</h4>
<p>Constructing valid SSTable files requires:</p>

<ul>
  <li>correct macro-block structure</li>
  <li>correct micro-block encoding</li>
  <li>ascending row keys (if ordered)</li>
  <li>correct checksum / metadata fields</li>
  <li>compatibility with compaction engine</li>
</ul>

<p>A single wrong byte may corrupt the block or crash compaction.</p>

<p>This is where system engineers and professors focus heavily on <strong>storage invariants</strong>.</p>

<h4 id="-challenge-4--io-saturation--throughput-optimization">• Challenge 4 — IO Saturation &amp; Throughput Optimization</h4>
<p>Key performance bottlenecks include:</p>

<ul>
  <li>disk write throughput</li>
  <li>network routing to servers</li>
  <li>memory allocator overhead</li>
  <li>thread synchronization</li>
  <li>per-row conversion cost</li>
</ul>

<p>Top teams achieved massive speedups by:</p>

<ul>
  <li>using large batch sizes</li>
  <li>minimizing per-row dynamic allocation</li>
  <li>leveraging zero-copy parsing</li>
  <li>tuning thread/partition scheduling</li>
  <li>compressing blocks efficiently</li>
</ul>

<h4 id="-challenge-5--correctness-under-parallelism">• Challenge 5 — Correctness Under Parallelism</h4>
<p>Even though bypass-load skips SQL and transactions, correctness still matters:</p>

<ul>
  <li>two worker threads cannot write conflicting blocks</li>
  <li>blocks must not violate partition boundaries</li>
  <li>metadata must reflect full import state</li>
  <li>ingest must be idempotent (or at least predictable)</li>
</ul>

<p>This shows deep understanding of <strong>distributed consistency and storage durability</strong>.</p>

<hr />

<h3 id="3-debugging-stories-and-lessons-learned">3. Debugging Stories and Lessons Learned</h3>

<p>Contestants frequently encounter real system-level bugs:</p>

<ul>
  <li><strong>SSTable blocks unreadable</strong> → due to row key mismatch or corrupted checksum</li>
  <li><strong>Cluster shows partial data</strong> → metadata updates incomplete</li>
  <li><strong>Import stalls</strong> → thread starvation or partition skew</li>
  <li><strong>Data silently lost</strong> → incorrect block offsets or buffer reuse bugs</li>
  <li><strong>Merge crashes</strong> → because ingest pipeline produced invalid storage layout</li>
</ul>

<p>The debugging mindset shifts from “fix my code” to <strong>“validate invariants across multiple subsystems.”</strong></p>

<p>This is exactly the type of experience that PhD advisors value.</p>

<hr />

<h3 id="4-skills-gained-from-the-final-round">4. Skills Gained from the Final Round</h3>

<p>The final round teaches a very different set of system skills than the MiniOB stage:</p>

<ul>
  <li><strong>Distributed systems thinking</strong>: partition routing, network paths, replica coordination</li>
  <li><strong>Storage engine internals</strong>: SSTable format, blocks, compaction, metadata</li>
  <li><strong>High-performance ingestion design</strong>: batching, parallel file writers, CPU–IO balancing</li>
  <li><strong>Debugging in real kernels</strong>: logs, hexdump, storage metadata inspection</li>
  <li><strong>Architectural reasoning</strong>: trade-offs between correctness, performance, and implementation complexity</li>
</ul>

<p>Overall, contestants move from “DBMS component-level understanding” to <strong>real distributed database engineering</strong>.</p>

<hr />

<h2 id="33-recommended-reading--write-ups">3.3 Recommended Reading &amp; Write-ups</h2>

<p>These write-ups provide high-quality insights into the final round challenge:</p>

<ul>
  <li>
    <p><strong>2022 Final Round Experience (very detailed analysis):</strong><br />
https://zhuanlan.zhihu.com/p/617520132</p>
  </li>
  <li>
    <p><strong>2023 Final Round Solution Breakdown:</strong><br />
https://zhuanlan.zhihu.com/p/677020265</p>
  </li>
  <li>
    <p><strong>Official OceanBase Final Round Blog:</strong><br />
https://open.oceanbase.com/blog/2325423616</p>
  </li>
</ul>

<p>Together, they illustrate design trade-offs, bottlenecks, and real implementation strategies used by top-performing teams.</p>

<hr />

<h1 id="5-reflection-and-conclusion">5. Reflection and Conclusion</h1>

<p>Participating in both stages of the competition—from MiniOB to the full OceanBase kernel—provides a holistic view of database systems engineering.</p>

<h3 id="1-from-components-to-systems">1. From Components to Systems</h3>
<p>MiniOB teaches component-level DBMS architecture.<br />
OceanBase requires designing system-level ingestion pipelines.</p>

<h3 id="2-the-value-of-invariants">2. The Value of Invariants</h3>
<p>Both stages emphasize metadata consistency, structured storage layout, and predictable error handling.</p>

<h3 id="3-engineering-realism">3. Engineering Realism</h3>
<p>Contestants learn how real systems fail, how to debug multi-module issues, and how to reason about performance and correctness simultaneously.</p>

<h3 id="4-what-i-would-do-differently">4. What I Would Do Differently</h3>
<ul>
  <li>instrument earlier</li>
  <li>adopt stronger testing strategies</li>
  <li>define clearer module boundaries</li>
  <li>profile before optimizing</li>
</ul>

<h3 id="5-closing-thoughts">5. Closing Thoughts</h3>
<p>This competition bridges academic foundations with industry-grade distributed systems.<br />
It provides a rigorous, hands-on understanding of database internals—from SQL to parser, storage, distributed ingestion, and performance engineering.</p>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="competitions" /><summary type="html"><![CDATA[A complete analysis of the OceanBase Database Competition (3rd Edition), including problem requirements, code implementation, architecture, and key design insights.]]></summary></entry><entry><title type="html">Database Learning Path</title><link href="https://junhaohu-tech.github.io/learning-path/learning-path-databases/" rel="alternate" type="text/html" title="Database Learning Path" /><published>2025-11-11T00:00:00+00:00</published><updated>2025-11-11T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/learning-path/learning-path-databases</id><content type="html" xml:base="https://junhaohu-tech.github.io/learning-path/learning-path-databases/"><![CDATA[<p>This learning path is for students who want to go beyond “I know SQL” and
build a <strong>system-level understanding of databases</strong> — enough to:</p>

<ul>
  <li>design schemas and write correct, efficient queries</li>
  <li>understand how relational engines and storage engines work</li>
  <li>use NoSQL systems such as MongoDB and Redis appropriately</li>
  <li>connect database concepts with <strong>distributed systems</strong> and modern data platforms</li>
</ul>

<p>The roadmap is divided into three levels:</p>

<ul>
  <li><strong>Beginner</strong></li>
  <li><strong>Intermediate</strong></li>
  <li><strong>Advanced</strong></li>
</ul>

<hr />

<h2 id="1-what-exactly-is-a-database">1. What exactly is a “database”?</h2>

<p>Before diving into resources, it’s helpful to clarify some overloaded terms.</p>

<h3 id="sql-vs-mysql">SQL vs. MySQL</h3>

<ul>
  <li><strong>SQL</strong> is a <em>language</em> (Structured Query Language).</li>
  <li><strong>MySQL</strong> is a relational <strong>database management system (DBMS)</strong> that uses SQL.</li>
</ul>

<hr />

<h3 id="mysql-vs-database">MySQL vs. “database”</h3>

<p>MySQL is one specific <strong>relational</strong> database system.<br />
Other relational engines include PostgreSQL, Oracle, SQL Server, etc.</p>

<hr />

<h3 id="sql-vs-sql-databases">SQL vs. SQL databases</h3>

<ul>
  <li><strong>SQL</strong> is the language.</li>
  <li>A <strong>SQL database</strong> is any relational engine that uses SQL (e.g., MySQL, PostgreSQL, SQLite).</li>
</ul>

<hr />

<h3 id="sql-databases-vs-nosql-databases">SQL databases vs. NoSQL databases</h3>

<ul>
  <li><strong>SQL databases:</strong> relational, schema-based, strong consistency by default.</li>
  <li><strong>NoSQL databases:</strong> document, key–value, column-family, graph models; more flexible or scalable.</li>
</ul>

<p>NoSQL is not a “replacement” for SQL — it is a complementary model.<br />
Choose based on workload and consistency requirements.</p>

<hr />

<h3 id="mysql-vs-postgresql">MySQL vs. PostgreSQL</h3>

<p>Both are relational databases:</p>

<ul>
  <li><strong>MySQL</strong>: widely used, strong for read-heavy workloads.</li>
  <li><strong>PostgreSQL</strong>: object-relational, highly extensible, standards-compliant.</li>
</ul>

<p>Either is fine for learning.</p>

<hr />

<h2 id="2-what-we-want-to-learn">2. What we want to learn</h2>

<p>A complete database learning path spans multiple systems:</p>

<ul>
  <li><strong>SQL language</strong></li>
  <li><strong>Relational engines</strong> (MySQL, PostgreSQL)</li>
  <li><strong>Document stores</strong> (MongoDB)</li>
  <li><strong>In-memory data structures</strong> (Redis)</li>
  <li><strong>Distributed systems foundations</strong></li>
</ul>

<hr />

<h2 id="prerequisites">Prerequisites</h2>

<ul>
  <li>Basic programming experience (Python, Java, Go, C++, etc.)</li>
  <li>Command-line familiarity</li>
  <li>Understanding of basic data structures</li>
</ul>

<hr />

<h1 id="-beginner-level">🔰 Beginner Level</h1>

<p><strong>Goal:</strong><br />
Learn SQL basics, relational databases, NoSQL overview, and get hands-on experience.</p>

<hr />

<h3 id="1-learn-sql-basics">1. Learn SQL basics</h3>

<p><strong>Resources</strong></p>

<ul>
  <li>W3Schools SQL: <a href="https://www.w3schools.com/sql/">https://www.w3schools.com/sql/</a></li>
  <li>Tutorial mirror 1: <a href="https://www.w3schools.cn/sql/">https://www.w3schools.cn/sql/</a></li>
  <li>Tutorial mirror 2: <a href="https://www.runoob.com/sql/sql-tutorial.html">https://www.runoob.com/sql/sql-tutorial.html</a></li>
</ul>

<p>Recommended practice after completing basics:<br />
Install MySQL locally and practice queries.</p>

<hr />

<h3 id="2-introductory-sql-books">2. Introductory SQL books</h3>

<p>Choose <strong>one</strong>:</p>

<h4 id="a-sql-essentials--mysql-essentials">(A) <em>SQL Essentials</em> / <em>MySQL Essentials</em></h4>

<p>Example download (one edition):<br />
<a href="https://drive.google.com/file/d/1QJv4JF4DWJdO7V_ZxWLzhis4yDuDxvno/view">https://drive.google.com/file/d/1QJv4JF4DWJdO7V_ZxWLzhis4yDuDxvno/view</a></p>

<p>Topics covered:</p>

<ul>
  <li>SELECT queries</li>
  <li>JOINs and aggregations</li>
  <li>schema design</li>
  <li>inserts/updates/deletes</li>
  <li>user and permission basics</li>
</ul>

<p>Workflow: read → type every query → run it.</p>

<h4 id="b-sql-basics-beginners-tutorial">(B) <em>SQL Basics (Beginner’s Tutorial)</em></h4>

<p>Example link:<br />
<a href="https://drive.google.com/file/d/12I-7TYkq8rGxjyeCOV_NX2r0sR3LxGht/view">https://drive.google.com/file/d/12I-7TYkq8rGxjyeCOV_NX2r0sR3LxGht/view</a></p>

<p>Uses PostgreSQL; highly visual, very beginner-friendly.</p>

<hr />

<h3 id="3-mongodb-learn-with-mongodb-university">3. MongoDB: Learn with MongoDB University</h3>

<ul>
  <li><a href="https://learn.mongodb.com/">https://learn.mongodb.com/</a></li>
</ul>

<p>This is MongoDB’s official training platform.<br />
Take <strong>MongoDB for Developers</strong> (7-week pace):</p>

<p>You will learn:</p>

<ul>
  <li>installation &amp; basic CRUD</li>
  <li>data modeling</li>
  <li>building a blog application</li>
  <li>assignments + quizzes each week</li>
</ul>

<p>Optional deeper reading:</p>

<p><strong>MongoDB: The Definitive Guide</strong><br />
<a href="https://drive.google.com/file/d/1CgQL2LjAOvAM8g6aVoY4_d5pWx9A5XL3/view">https://drive.google.com/file/d/1CgQL2LjAOvAM8g6aVoY4_d5pWx9A5XL3/view</a></p>

<hr />

<h3 id="4-general-database-theory">4. General database theory</h3>

<p>Read selected chapters (not cover-to-cover) from:</p>

<p><strong>Database System Concepts</strong><br />
<a href="https://drive.google.com/file/d/11rIdRiVYrFChEiqmYCuVpN6A4wgTErMw/view">https://drive.google.com/file/d/11rIdRiVYrFChEiqmYCuVpN6A4wgTErMw/view</a></p>

<p>Focus on:</p>

<ul>
  <li>relational model</li>
  <li>storage &amp; indexing</li>
  <li>transactions</li>
  <li>DB architecture</li>
</ul>

<hr />

<h3 id="5-redis-basics">5. Redis basics</h3>

<p>Pick <strong>one</strong>:</p>

<ul>
  <li>
    <p><strong>Redis Beginner’s Guide</strong><br />
<a href="https://drive.google.com/file/d/1aavGDWBzlZwbwDciAe8VLBisW5yJ9eG4/view">https://drive.google.com/file/d/1aavGDWBzlZwbwDciAe8VLBisW5yJ9eG4/view</a></p>
  </li>
  <li>
    <p><strong>Redis Handbook</strong><br />
(overview of data types, operations, usage patterns)</p>
  </li>
</ul>

<p>Optional video course:<br />
Redis 6 from Beginner to Advanced<br />
<a href="https://www.bilibili.com/video/BV1Rv41177Af/">https://www.bilibili.com/video/BV1Rv41177Af/</a></p>

<hr />

<h3 id="6-distributed-systems-perspective">6. Distributed systems perspective</h3>

<p><strong>Distributed Systems for Fun and Profit</strong><br />
<a href="https://book.mixu.net/distsys/">https://book.mixu.net/distsys/</a></p>

<p>A short and accessible overview of distributed thinking — essential context for distributed databases.</p>

<hr />

<h3 id="7-optional-hbase">7. Optional: HBase</h3>

<p><strong>HBase: The Definitive Guide</strong><br />
<a href="https://drive.google.com/file/d/1pHaX4c0iPsL24OKhg46ZcSjz8ccwlJIm/view">https://drive.google.com/file/d/1pHaX4c0iPsL24OKhg46ZcSjz8ccwlJIm/view</a></p>

<hr />

<h1 id="️-intermediate-level">⚙️ Intermediate Level</h1>

<p><strong>Goal:</strong><br />
Understand SQL engine internals, storage engines, transactions, NoSQL internals, and official docs.</p>

<hr />

<h3 id="1-cmu-15-445--15-645-database-systems">1. CMU 15-445 / 15-645: Database Systems</h3>

<ul>
  <li>Course site: <a href="https://15445.courses.cs.cmu.edu/fall2017/">https://15445.courses.cs.cmu.edu/fall2017/</a></li>
  <li>Lecture recordings: <a href="https://www.bilibili.com/video/BV1LA411H7Gj/">https://www.bilibili.com/video/BV1LA411H7Gj/</a></li>
</ul>

<p>Covers:</p>

<ul>
  <li>storage and buffer pools</li>
  <li>B+-trees</li>
  <li>query optimization</li>
  <li>MVCC</li>
  <li>logging and recovery</li>
</ul>

<p>Assignments are based on <strong>BusTub</strong>, a real DBMS implementation.</p>

<hr />

<h3 id="2-mysql-official-documentation">2. MySQL official documentation</h3>

<ul>
  <li><a href="https://dev.mysql.com/doc/">https://dev.mysql.com/doc/</a></li>
</ul>

<p>How to read:</p>

<ul>
  <li>browse the doc structure first</li>
  <li>look up specific topics deeply</li>
  <li>read entire chapters when exploring a new feature</li>
</ul>

<hr />

<h3 id="3-innodb-internals">3. InnoDB internals</h3>

<p><strong>MySQL Technical Insider: The InnoDB Storage Engine</strong><br />
<a href="https://drive.google.com/file/d/1kSQsS9-_QujtdpMVVV2Lnvy0Olv63bXa/view">https://drive.google.com/file/d/1kSQsS9-_QujtdpMVVV2Lnvy0Olv63bXa/view</a></p>

<p>Recommended chapters: 2, 4, 5.</p>

<hr />

<h3 id="4-mongodb-official-documentation">4. MongoDB official documentation</h3>

<ul>
  <li><a href="https://www.mongodb.com/docs/manual/">https://www.mongodb.com/docs/manual/</a></li>
</ul>

<p>Best source for modeling, aggregation, indexes, deployments.</p>

<hr />

<h3 id="5-redis-internals">5. Redis internals</h3>

<p><strong>Redis Design and Implementation</strong><br />
<a href="https://drive.google.com/file/d/1PyPTLFGywqbHEmKvHQrV0rjJD4THPjcJ/view">https://drive.google.com/file/d/1PyPTLFGywqbHEmKvHQrV0rjJD4THPjcJ/view</a></p>

<p>Paired with source code reading → excellent for understanding systems internals.</p>

<hr />

<h3 id="6-redis-official-documentation-and-references">6. Redis official documentation and references</h3>

<ul>
  <li>Official docs: <a href="https://redis.io/documentation">https://redis.io/documentation</a></li>
  <li>Data types: <a href="https://redis.io/topics/data-types">https://redis.io/topics/data-types</a></li>
  <li>Redis in Action:<br />
<a href="https://drive.google.com/file/d/1pPgZnvelXPAIxPCz8eMbJLFkwjeddpqo/view">https://drive.google.com/file/d/1pPgZnvelXPAIxPCz8eMbJLFkwjeddpqo/view</a></li>
  <li>Redis Command Reference:<br />
<a href="https://drive.google.com/file/d/1WKBA4pg0uRM24NiThUXW8rAOTNfPR3IT/view">https://drive.google.com/file/d/1WKBA4pg0uRM24NiThUXW8rAOTNfPR3IT/view</a></li>
</ul>

<hr />

<h3 id="7-distributed-systems-again">7. Distributed systems (again)</h3>

<p>MIT 6.824 Distributed Systems</p>
<ul>
  <li><a href="https://pdos.csail.mit.edu/6.824/schedule.html">https://pdos.csail.mit.edu/6.824/schedule.html</a></li>
  <li><a href="https://www.youtube.com/@6.824">https://www.youtube.com/@6.824</a></li>
  <li><a href="https://www.bilibili.com/video/BV1x7411M7Sf/">https://www.bilibili.com/video/BV1x7411M7Sf/</a></li>
</ul>

<p>Implement Raft, MapReduce, replicated key-value stores.</p>

<hr />

<h3 id="8-postgresql-official-documentation">8. PostgreSQL official documentation</h3>

<ul>
  <li><a href="https://www.postgresql.org/docs/">https://www.postgresql.org/docs/</a></li>
</ul>

<p>Deep, well-structured, and great for understanding relational engine design.</p>

<hr />

<h1 id="-advanced-level">🚀 Advanced Level</h1>

<p><strong>Goal:</strong><br />
Performance tuning, indexing, internals, distributed storage, and research papers.</p>

<hr />

<h3 id="1-indexing-and-performance">1. Indexing and performance</h3>

<p><strong>Database Index Design and Optimization</strong><br />
<a href="https://drive.google.com/file/d/10SrTxPtZVrI4f93m7AmAXcutWJvYGZKe/view">https://drive.google.com/file/d/10SrTxPtZVrI4f93m7AmAXcutWJvYGZKe/view</a></p>

<p>Learn:</p>

<ul>
  <li>how DB engines choose access paths</li>
  <li>estimating query costs</li>
  <li>designing and tuning indexes with first principles</li>
</ul>

<hr />

<h3 id="2-high-performance-mysql">2. High-performance MySQL</h3>

<p><strong>High Performance MySQL</strong><br />
<a href="https://drive.google.com/file/d/1nwhSrOXYufqbzIMC99cHQNjL7IZRIWhq/view">https://drive.google.com/file/d/1nwhSrOXYufqbzIMC99cHQNjL7IZRIWhq/view</a></p>

<p>Covers:</p>

<ul>
  <li>indexing</li>
  <li>schema design</li>
  <li>replication</li>
  <li>sharding</li>
  <li>hardware &amp; server configuration</li>
  <li>performance tuning</li>
</ul>

<hr />

<h3 id="3-advanced-redis-books">3. Advanced Redis books</h3>

<ul>
  <li>
    <p><strong>Redis Development and Operations</strong><br />
<a href="https://drive.google.com/file/d/1G2tCdsy5ph10n_eq6Gzv8LiqWLBUIBtg/view">https://drive.google.com/file/d/1G2tCdsy5ph10n_eq6Gzv8LiqWLBUIBtg/view</a></p>
  </li>
  <li>
    <p><strong>Redis Deep Dive: Core Principles and Practical Applications</strong><br />
<a href="https://drive.google.com/file/d/1VyLppzqXyxseaIWjFKGODg1_zESlFkJO/view">https://drive.google.com/file/d/1VyLppzqXyxseaIWjFKGODg1_zESlFkJO/view</a></p>
  </li>
</ul>

<hr />

<h3 id="4-cmu-15-721-advanced-database-systems">4. CMU 15-721 (Advanced Database Systems)</h3>

<ul>
  <li>Example lecture link: <a href="https://www.bilibili.com/video/BV1mJ41147KK/">https://www.bilibili.com/video/BV1mJ41147KK/</a></li>
</ul>

<p>Graduate-level seminar focusing on:</p>

<ul>
  <li>modern DBMS research</li>
  <li>column stores</li>
  <li>log-structured storage</li>
  <li>query optimizers</li>
  <li>HTAP</li>
  <li>distributed transactions</li>
</ul>

<hr />

<h3 id="5-googles-foundational-data-systems-papers">5. Google’s foundational data systems papers</h3>

<ul>
  <li><strong>Google File System (GFS)</strong></li>
  <li><strong>MapReduce</strong></li>
  <li><strong>Bigtable</strong></li>
</ul>

<p>Example links:<br />
<a href="https://drive.google.com/file/d/1Gm6ICrMofFzRUd9B4GBvVLY3tZH-z9xX/view">https://drive.google.com/file/d/1Gm6ICrMofFzRUd9B4GBvVLY3tZH-z9xX/view</a><br />
<a href="https://drive.google.com/file/d/1wzaVK5PStnudeWA_PTvE5uL-VEw9OaWz/view">https://drive.google.com/file/d/1wzaVK5PStnudeWA_PTvE5uL-VEw9OaWz/view</a><br />
<a href="https://drive.google.com/file/d/1nhbid-TlM73bCKQ4G3DwNRxTInAlo8fR/view">https://drive.google.com/file/d/1nhbid-TlM73bCKQ4G3DwNRxTInAlo8fR/view</a></p>

<hr />

<h3 id="6-paper-reading">6. Paper reading</h3>

<p><strong>Readings in Databases</strong><br />
<a href="https://github.com/rxin/db-readings">https://github.com/rxin/db-readings</a></p>

<p>Pick a theme → read 2–3 papers → write notes.</p>

<hr />

<h2 id="-putting-it-all-together">🧭 Putting it all together</h2>

<p>One recommended progression:</p>

<ol>
  <li><strong>Beginner</strong>
    <ul>
      <li>Learn SQL via tutorials + one book</li>
      <li>Install MySQL/PostgreSQL and practice</li>
      <li>Learn MongoDB &amp; Redis basics</li>
    </ul>
  </li>
  <li><strong>Intermediate</strong>
    <ul>
      <li>Take CMU 15-445</li>
      <li>Read selected chapters of Database System Concepts</li>
      <li>Dive into MySQL/MongoDB/Redis documentation</li>
      <li>Take MIT 6.824 to connect DBs with distributed systems</li>
    </ul>
  </li>
  <li><strong>Advanced</strong>
    <ul>
      <li>Read about indexing and optimization</li>
      <li>Study engine internals (InnoDB, Postgres, Redis)</li>
      <li>Take CMU 15-721</li>
      <li>Start reading DB research papers</li>
    </ul>
  </li>
</ol>

<p>Most importantly: <strong>alternate theory and hands-on practice</strong>.<br />
Databases become intuitive only when you build, debug, measure, and reason about real systems.</p>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="learning-path" /><summary type="html"><![CDATA[A structured roadmap for learning databases—from SQL fundamentals to relational engines, NoSQL systems, and advanced internals and research topics.]]></summary></entry><entry><title type="html">Distributed Systems Learning Path</title><link href="https://junhaohu-tech.github.io/learning-path/learning-path-distributed-systems/" rel="alternate" type="text/html" title="Distributed Systems Learning Path" /><published>2025-11-11T00:00:00+00:00</published><updated>2025-11-11T00:00:00+00:00</updated><id>https://junhaohu-tech.github.io/learning-path/learning-path-distributed-systems</id><content type="html" xml:base="https://junhaohu-tech.github.io/learning-path/learning-path-distributed-systems/"><![CDATA[<p>Building intuition and skill in <strong>distributed systems</strong> takes time.<br />
This roadmap is organized into three levels — <strong>Beginner</strong>, <strong>Intermediate</strong>, and <strong>Advanced</strong> — and is designed for students who eventually want to <strong>do research</strong> or <strong>build real systems</strong> in distributed systems and databases.</p>

<hr />

<h2 id="-big-picture">🧩 Big Picture</h2>

<p>For the purposes of learning, we can roughly break the space into four areas:</p>

<ul>
  <li><strong>Distributed storage</strong> – file systems, databases, key–value stores, table stores</li>
  <li><strong>Distributed computation</strong> – large-scale data processing frameworks</li>
  <li><strong>Distributed communication &amp; coordination</strong> – RPC, consensus, service coordination</li>
  <li><strong>Distributed machine learning</strong> – training and inference at scale</li>
</ul>

<p>A solid learning path touches all four, with progressively more depth.</p>

<hr />

<h2 id="-prerequisites">🧠 Prerequisites</h2>

<p>Before diving in:</p>

<ul>
  <li>Be comfortable with at least one systems-oriented language:<br />
<strong>Go</strong>, <strong>Java</strong>, <strong>C++</strong>, or <strong>Rust</strong> (Python is fine for scripting and prototyping).</li>
  <li>Have basic background in:
    <ul>
      <li>operating systems (threads, processes, scheduling)</li>
      <li>networking (sockets, RPC, basic protocols)</li>
      <li>data structures and algorithms</li>
    </ul>
  </li>
</ul>

<p>You <strong>don’t</strong> need to be an expert; you will reinforce these along the way.</p>

<hr />

<h2 id="-knowledge-map">🧱 Knowledge Map</h2>

<h3 id="1-distributed-storage">1. Distributed Storage</h3>

<p><strong>Architecture types</strong></p>

<ul>
  <li>Central coordinator vs. decentralized peer-to-peer</li>
  <li>Shared-nothing vs. shared-storage</li>
</ul>

<p><strong>System families</strong></p>

<ul>
  <li>Distributed file systems</li>
  <li>Distributed databases</li>
  <li>Distributed key–value stores</li>
  <li>Distributed table stores and column stores</li>
</ul>

<hr />

<h3 id="2-distributed-computation">2. Distributed Computation</h3>

<ul>
  <li>Hadoop MapReduce</li>
  <li>Apache Spark</li>
  <li>Apache Flink</li>
  <li>How they differ in:
    <ul>
      <li>execution model</li>
      <li>fault tolerance</li>
      <li>latency vs. throughput trade-offs</li>
    </ul>
  </li>
</ul>

<hr />

<h3 id="3-distributed-communication--coordination">3. Distributed Communication &amp; Coordination</h3>

<ul>
  <li>RPC frameworks: gRPC, Thrift</li>
  <li>Coordination systems: ZooKeeper, etcd</li>
  <li>Consensus protocols: Raft, Paxos, Zab</li>
</ul>

<hr />

<h3 id="4-distributed-machine-learning">4. Distributed Machine Learning</h3>

<ul>
  <li>Spark MLlib</li>
  <li>Parameter servers</li>
  <li>Distributed TensorFlow / PyTorch</li>
  <li>Data-parallel vs. model-parallel patterns</li>
</ul>

<p>You don’t need to master all of these at once. The rest of this roadmap gives a sequence of <strong>concrete resources</strong> to follow.</p>

<hr />

<h1 id="-beginner-level">🧩 Beginner Level</h1>

<p>Goal:</p>
<blockquote>
  <p>Build core intuition for <strong>replication, consistency, and failure</strong> while implementing small systems.</p>
</blockquote>

<hr />

<h3 id="0-high-level-overview">0. High-level overview</h3>

<p><strong>Distributed Systems for Fun and Profit</strong></p>
<ul>
  <li>🔗 <a href="https://book.mixu.net/distsys/">https://book.mixu.net/distsys/</a></li>
  <li>Short, highly readable book.</li>
  <li>Explains key ideas like replication, consistency, and design trade-offs behind systems such as Dynamo, Bigtable, and Hadoop.</li>
</ul>

<hr />

<h3 id="1-core-course-mit-6824-distributed-systems">1. Core course: MIT 6.824 Distributed Systems</h3>

<ul>
  <li>📄 Course page: <a href="https://pdos.csail.mit.edu/6.824/schedule.html">https://pdos.csail.mit.edu/6.824/schedule.html</a></li>
  <li>🎥 YouTube: <a href="https://www.youtube.com/@6.824">https://www.youtube.com/@6.824</a></li>
  <li>🎥 Bilibili:
    <ul>
      <li><a href="https://www.bilibili.com/video/BV1x7411M7Sf/">https://www.bilibili.com/video/BV1x7411M7Sf/</a></li>
      <li><a href="https://www.bilibili.com/video/BV1CU4y1P7PE/">https://www.bilibili.com/video/BV1CU4y1P7PE/</a></li>
    </ul>
  </li>
</ul>

<p><strong>Why this course</strong></p>

<ul>
  <li>Teaches fundamentals through <strong>Go</strong> implementations.</li>
  <li>Labs cover:
    <ul>
      <li>MapReduce</li>
      <li>Raft consensus</li>
      <li>Replicated key–value servers</li>
    </ul>
  </li>
  <li>You will <strong>feel</strong> how failures and timeouts behave in practice.</li>
</ul>

<p>👉 If you’re new to Go:</p>
<ul>
  <li>Start with the official tour: <a href="https://go.dev/tour/welcome/1">https://go.dev/tour/welcome/1</a></li>
</ul>

<hr />

<h3 id="1-optional-cmu-15-440-distributed-systems">1′. Optional: CMU 15-440 Distributed Systems</h3>

<ul>
  <li>📄 Course homepage: <a href="https://www.cs.cmu.edu/~dga/15-440/S14/">https://www.cs.cmu.edu/~dga/15-440/S14/</a></li>
</ul>

<p>A solid undergraduate-level course.<br />
If you want a smoother ramp-up, one option is:</p>

<blockquote>
  <p><strong>15-440 → 6.824 → 15-712 (later at intermediate/advanced).</strong></p>
</blockquote>

<hr />

<h3 id="1-conceptual-complement-cambridge-concurrent-and-distributed-systems">1″. Conceptual complement: Cambridge Concurrent and Distributed Systems</h3>

<ul>
  <li>📄 Course materials: <a href="https://www.cl.cam.ac.uk/teaching/2021/ConcDisSys/materials.html">https://www.cl.cam.ac.uk/teaching/2021/ConcDisSys/materials.html</a></li>
  <li>🎥 YouTube playlist: <a href="https://www.youtube.com/watch?v=UEAMfLPZZhE&amp;list=PLeKd45zvjcDFUEv_ohr_HdUFe97RItdiB">https://www.youtube.com/watch?v=UEAMfLPZZhE&amp;list=PLeKd45zvjcDFUEv_ohr_HdUFe97RItdiB</a></li>
</ul>

<p>Taught by <strong>Martin Kleppmann</strong> (author of <em>Designing Data-Intensive Applications</em>).<br />
Great for developing a clean conceptual model of concurrency and communication.</p>

<hr />

<h3 id="2-database-fundamentals-cmu-15-445">2. Database fundamentals: CMU 15-445</h3>

<p><strong>CMU 15-445 Intro to Database Systems</strong></p>

<ul>
  <li>🎥 YouTube: <a href="https://www.youtube.com/watch?v=vdPALZ-GCfI&amp;list=PLSE8ODhjZXjbj8BMuIrRcacnQh20hmY9g">https://www.youtube.com/watch?v=vdPALZ-GCfI&amp;list=PLSE8ODhjZXjbj8BMuIrRcacnQh20hmY9g</a></li>
  <li>🎥 Bilibili: <a href="https://www.bilibili.com/video/av85655193/">https://www.bilibili.com/video/av85655193/</a></li>
</ul>

<p>Covers:</p>

<ul>
  <li>storage and buffer pool</li>
  <li>index structures</li>
  <li>query execution</li>
  <li>transactions and MVCC</li>
</ul>

<p>Labs use <strong>bustub</strong> in C++.<br />
If you are not a C++ user, you can still follow lectures and read the code at a higher level.</p>

<hr />

<h3 id="3-core-reading-designing-data-intensive-applications-ddia">3. Core reading: Designing Data-Intensive Applications (DDIA)</h3>

<p><strong>Designing Data-Intensive Applications</strong> by Martin Kleppmann</p>

<ul>
  <li>Online copy: <a href="https://ddia.qtmuniao.com/#/">https://ddia.qtmuniao.com/#/</a></li>
  <li>Slides (one example): <a href="https://drive.google.com/file/d/1s2MfNjS5RH6DK0gXYMzVZKlzsnacZ6Uq/view">https://drive.google.com/file/d/1s2MfNjS5RH6DK0gXYMzVZKlzsnacZ6Uq/view</a></li>
</ul>

<p>What you get:</p>

<ul>
  <li>unified big-picture view of storage, streams, and batch/online systems</li>
  <li>explanations for <em>why</em> systems like Kafka, Cassandra, and Spanner look the way they do</li>
  <li>many concrete design trade-offs and real-world stories</li>
</ul>

<hr />

<h3 id="3-optional-textbook-distributed-systems--concepts-and-design">3′. Optional textbook: Distributed Systems – Concepts and Design</h3>

<p><strong>Distributed Systems: Concepts and Design</strong> (Coulouris et al.)</p>

<ul>
  <li>PDF example: <a href="https://drive.google.com/file/d/19QgnFpwS5nJHzPC_weV_N9BoBACiC3oc/view">https://drive.google.com/file/d/19QgnFpwS5nJHzPC_weV_N9BoBACiC3oc/view</a></li>
</ul>

<p>Contains a traditional textbook treatment of distributed systems.<br />
Good as a reference to clarify terms and models.</p>

<hr />

<h3 id="3-short-notes-notes-on-distributed-systems-for-young-bloods">3″. Short notes: Notes on Distributed Systems for Young Bloods</h3>

<ul>
  <li>Article: <a href="https://www.somethingsimilar.com/2013/01/14/notes-on-distributed-systems-for-young-bloods/">https://www.somethingsimilar.com/2013/01/14/notes-on-distributed-systems-for-young-bloods/</a></li>
</ul>

<p>Short, practical notes on what makes distributed systems hard in real life.</p>

<hr />

<h1 id="-intermediate-level">🧱 Intermediate Level</h1>

<p>Goal:</p>
<blockquote>
  <p>Connect coursework to <strong>theoretical models</strong> and <strong>real research papers</strong>.</p>
</blockquote>

<hr />

<h3 id="1-roadmap-paper-distributed-systems-theory-for-the-distributed-systems-engineer">1. Roadmap paper: Distributed Systems Theory for the Distributed Systems Engineer</h3>

<ul>
  <li>Article: <a href="https://www.the-paper-trail.org/post/2014-08-09-distributed-systems-theory-for-the-distributed-systems-engineer/">https://www.the-paper-trail.org/post/2014-08-09-distributed-systems-theory-for-the-distributed-systems-engineer/</a></li>
</ul>

<p>This is a <em>paper roadmap</em> — it lists key results (CAP, FLP, Paxos, etc.) and tells you why they matter for engineers.</p>

<hr />

<h3 id="2-advanced-database-systems-cmu-15-721">2. Advanced database systems: CMU 15-721</h3>

<ul>
  <li>Course site: <a href="https://15721.courses.cs.cmu.edu/spring2020/schedule.html">https://15721.courses.cs.cmu.edu/spring2020/schedule.html</a></li>
  <li>Bilibili: <a href="https://www.bilibili.com/video/BV1VE411f7kP/">https://www.bilibili.com/video/BV1VE411f7kP/</a></li>
</ul>

<p>A graduate-level seminar focusing on:</p>

<ul>
  <li>reading and presenting papers</li>
  <li>understanding the design of modern database systems</li>
  <li>thinking like a systems researcher</li>
</ul>

<hr />

<h3 id="2-seminar-style-ds-course-stanford-cs244b">2′. Seminar-style DS course: Stanford CS244b</h3>

<ul>
  <li>Course site: <a href="http://www.scs.stanford.edu/20sp-cs244b/">http://www.scs.stanford.edu/20sp-cs244b/</a></li>
</ul>

<p>Discussion-based, centered around classic and modern distributed systems papers.<br />
Good for training your <strong>paper reading + presentation</strong> skills.</p>

<hr />

<h3 id="3-textbook-distributed-systems-tanenbaum--van-steen">3. Textbook: Distributed Systems (Tanenbaum &amp; van Steen)</h3>

<ul>
  <li>Book site: <a href="https://www.distributed-systems.net/index.php/books/ds3/">https://www.distributed-systems.net/index.php/books/ds3/</a></li>
</ul>

<p>Nine core chapters:</p>

<ol>
  <li>Introduction</li>
  <li>Architecture</li>
  <li>Processes</li>
  <li>Communication</li>
  <li>Naming</li>
  <li>Coordination</li>
  <li>Consistency</li>
  <li>Fault Tolerance</li>
  <li>Security</li>
</ol>

<p>Comes with figures and some Python examples.<br />
It’s a good “second textbook” once you already know the basics.</p>

<hr />

<h3 id="4-practical-storage-book-large-scale-distributed-storage-systems">4. Practical storage book: Large-Scale Distributed Storage Systems</h3>

<ul>
  <li>PDF example: <a href="https://drive.google.com/file/d/1f27FfjzHU9hmwgVKLnUo5LNj-8oOnH6e/view">https://drive.google.com/file/d/1f27FfjzHU9hmwgVKLnUo5LNj-8oOnH6e/view</a></li>
</ul>

<p>Short and practical discussion of:</p>

<ul>
  <li>different kinds of storage systems</li>
  <li>their architectures</li>
  <li>where the bottlenecks come from</li>
</ul>

<hr />

<h3 id="4-theory-deep-dive-optional-nancy-lynch--distributed-algorithms">4′. Theory deep dive (optional): Nancy Lynch – Distributed Algorithms</h3>

<ul>
  <li>PDF example: <a href="https://drive.google.com/file/d/1h_cbTqzzhIek6qRpkhFLuTaCkqpiBDSF/view">https://drive.google.com/file/d/1h_cbTqzzhIek6qRpkhFLuTaCkqpiBDSF/view</a></li>
</ul>

<p>Mathematically rigorous and challenging.<br />
Best approached once you already have some intuition about consensus and failures.</p>

<hr />

<h1 id="-advanced-level">🧬 Advanced Level</h1>

<p>Goal:</p>
<blockquote>
  <p>Read and implement real systems; understand research problems and trade-offs at scale.</p>
</blockquote>

<hr />

<h3 id="1-the-google--amazon-papers">1. The “Google &amp; Amazon” papers</h3>

<p>These four papers are foundational:</p>

<ul>
  <li><strong>GFS</strong> – Google File System</li>
  <li><strong>MapReduce</strong> – programming model + runtime</li>
  <li><strong>Bigtable</strong> – wide-column storage</li>
  <li><strong>Dynamo</strong> – highly available key–value store</li>
</ul>

<p>Example links / collections:</p>

<ul>
  <li>Overview article (Chinese): <a href="https://blog.csdn.net/u011510825/article/details/122816587">https://blog.csdn.net/u011510825/article/details/122816587</a></li>
  <li>GFS: <a href="https://drive.google.com/file/d/1xPIAG96AC--OpntxPymlMFOgbjOteL1W/view">https://drive.google.com/file/d/1xPIAG96AC--OpntxPymlMFOgbjOteL1W/view</a></li>
  <li>MapReduce: <a href="https://drive.google.com/file/d/1km2uZSV0UFcdPsHUOI-rQCwJQxWBQdlw/view">https://drive.google.com/file/d/1km2uZSV0UFcdPsHUOI-rQCwJQxWBQdlw/view</a></li>
  <li>Bigtable: <a href="https://drive.google.com/file/d/1161vjEDJ33tWqGcATGZ5xpoEkuwwGlwU/view">https://drive.google.com/file/d/1161vjEDJ33tWqGcATGZ5xpoEkuwwGlwU/view</a></li>
  <li>Dynamo: <a href="https://drive.google.com/file/d/1RHkdJEEUKYoCJ5_D6jMmkQvORQOVMpu0/view">https://drive.google.com/file/d/1RHkdJEEUKYoCJ5_D6jMmkQvORQOVMpu0/view</a></li>
</ul>

<hr />

<h3 id="2-hands-on-practicum-tidb-talent-plan">2. Hands-on practicum: TiDB Talent Plan</h3>

<p><strong>PingCAP TiDB Talent Plan</strong></p>

<ul>
  <li><a href="https://tidb.net/talent-plan">https://tidb.net/talent-plan</a></li>
</ul>

<p>Guided labs to implement components inspired by <strong>TiDB/TiKV</strong> using Go or Rust:</p>

<ul>
  <li>storage engine</li>
  <li>Raft-based replication</li>
  <li>simple distributed transactions</li>
</ul>

<p>Perfect follow-up after MIT 6.824.</p>

<hr />

<h3 id="3-curated-reading-lists">3. Curated reading lists</h3>

<p>Some good collections:</p>

<ul>
  <li><strong>Readings in Databases</strong>: <a href="https://github.com/rxin/db-readings">https://github.com/rxin/db-readings</a></li>
  <li><strong>Awesome Distributed Systems</strong>: <a href="https://github.com/theanalyst/awesome-distributed-systems">https://github.com/theanalyst/awesome-distributed-systems</a></li>
  <li><strong>Qix DS list</strong>: <a href="https://github.com/ty4z2008/Qix/blob/master/ds.md">https://github.com/ty4z2008/Qix/blob/master/ds.md</a></li>
  <li><strong>ascrutae gist</strong> (Chinese notes and links): <a href="https://gist.github.com/ascrutae/7fbc3681ff6e7f68fc908e196eac980e">https://gist.github.com/ascrutae/7fbc3681ff6e7f68fc908e196eac980e</a></li>
</ul>

<p>Pick a small set of papers at a time and <strong>write notes</strong> after reading.</p>

<hr />

<h3 id="4-consensus--transactions-papers">4. Consensus &amp; transactions papers</h3>

<p>Examples worth reading (at least in summary):</p>

<ul>
  <li><strong>Raft</strong> – understandable consensus; read the paper and optionally the thesis</li>
  <li><strong>ZooKeeper</strong> – Zab protocol; coordination service design</li>
  <li><strong>Multi-Paxos</strong> – practical Paxos in repeated settings</li>
  <li><strong>Percolator</strong> – transaction layer on top of Bigtable</li>
  <li><strong>Megastore</strong> – partitioned stores with per-partition consensus</li>
  <li><strong>Consensus on Transaction Commit</strong> – Paxos-based two-phase commit</li>
  <li><strong>A Note on Distributed Systems</strong>: <a href="https://citeseerx.ist.psu.edu/doc/10.1.1.41.7628">https://citeseerx.ist.psu.edu/doc/10.1.1.41.7628</a></li>
  <li><strong>A Brief Tour of FLP Impossibility</strong>: <a href="https://www.the-paper-trail.org/post/2008-08-13-a-brief-tour-of-flp-impossibility/">https://www.the-paper-trail.org/post/2008-08-13-a-brief-tour-of-flp-impossibility/</a></li>
</ul>

<p>For PhD applications, writing <strong>paper notes</strong> on a subset of these is excellent evidence of depth.</p>

<hr />

<h3 id="5-open-source-projects-to-study">5. Open-source projects to study</h3>

<p>You don’t need to understand every line of code. Start by tracing:</p>

<ul>
  <li>the write path</li>
  <li>the read path</li>
  <li>how failures are detected and handled</li>
</ul>

<p><strong>Storage:</strong></p>

<ul>
  <li>Hadoop: <a href="https://github.com/apache/hadoop">https://github.com/apache/hadoop</a> (Java)</li>
  <li>SeaweedFS: <a href="https://github.com/seaweedfs/seaweedfs">https://github.com/seaweedfs/seaweedfs</a> (Go)</li>
  <li>MinIO: <a href="https://github.com/minio/minio">https://github.com/minio/minio</a> (Go)</li>
  <li>TiDB: <a href="https://github.com/pingcap/tidb">https://github.com/pingcap/tidb</a> (Go)</li>
</ul>

<p><strong>Consensus &amp; coordination:</strong></p>

<ul>
  <li>etcd: <a href="https://github.com/etcd-io/etcd">https://github.com/etcd-io/etcd</a> (Go)</li>
  <li>ZooKeeper: <a href="https://github.com/apache/zookeeper">https://github.com/apache/zookeeper</a> (Java)</li>
</ul>

<p><strong>Computation:</strong></p>

<ul>
  <li>Spark: <a href="https://github.com/apache/spark">https://github.com/apache/spark</a> (Scala)</li>
  <li>Flink: <a href="https://github.com/apache/flink">https://github.com/apache/flink</a> (Java)</li>
  <li>Ray: <a href="https://github.com/ray-project/ray">https://github.com/ray-project/ray</a> (Python/C++)</li>
</ul>

<hr />

<h3 id="6-reinforce-prerequisites-as-needed">6. Reinforce prerequisites as needed</h3>

<p>As you go deeper, it’s normal to circle back to:</p>

<ul>
  <li>computer architecture</li>
  <li>operating systems</li>
  <li>networking</li>
  <li>compilers / runtimes</li>
</ul>

<p>Distributed systems sit on top of all of these.</p>

<hr />

<h2 id="-summary">🧭 Summary</h2>

<table>
  <thead>
    <tr>
      <th>Level</th>
      <th>Focus</th>
      <th>Main Goal</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>Beginner</strong></td>
      <td>Labs + core concepts (6.824, 15-445, DDIA)</td>
      <td>Build intuition and implementation skills</td>
    </tr>
    <tr>
      <td><strong>Intermediate</strong></td>
      <td>Paper roadmaps and advanced courses</td>
      <td>Connect theory with real systems</td>
    </tr>
    <tr>
      <td><strong>Advanced</strong></td>
      <td>Classic papers, open-source, and research topics</td>
      <td>Think and work like a systems researcher/engineer</td>
    </tr>
  </tbody>
</table>

<p>This roadmap is not meant to be followed rigidly.<br />
Pick a starting point that fits your background, <strong>alternate between theory and implementation</strong>, and write down what you learn — that’s how the knowledge becomes your own.</p>]]></content><author><name>JH H</name><email>none@example.org</email></author><category term="learning-path" /><summary type="html"><![CDATA[A complete roadmap for learning distributed systems — from beginner fundamentals to advanced research and open-source engineering.]]></summary></entry></feed>