<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kernel on digitalitem: Claude skills library and product lab</title><link>https://digitalitem.online/en/tags/kernel/</link><description>Recent content in Kernel on digitalitem: Claude skills library and product lab</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 22 Oct 2026 10:30:00 +0000</lastBuildDate><atom:link href="https://digitalitem.online/en/tags/kernel/index.xml" rel="self" type="application/rss+xml"/><item><title>Database Kernel (6): WAL, Replay and Checkpoint</title><link>https://digitalitem.online/en/posts/plan-wal-checkpoint/</link><pubDate>Thu, 22 Oct 2026 10:30:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-wal-checkpoint/</guid><description>&lt;p&gt;Transactions make concurrency correct, but machines crash. What recovers the system? An &lt;strong&gt;append-only log&lt;/strong&gt;, plus a marker for where to start replaying.&lt;/p&gt;
&lt;p&gt;The final post in the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; series.&lt;/p&gt;
&lt;h2 id="1-whats-in-the-wal"&gt;1. What&amp;rsquo;s in the WAL&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;walog&lt;/code&gt; is a file storing redo log entries sequentially:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Written when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;insert / delete / update&lt;/td&gt;
&lt;td&gt;a transaction writes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;flush&lt;/td&gt;
&lt;td&gt;a transaction commits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;checkpoint&lt;/td&gt;
&lt;td&gt;everything before it is already applied to tables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;create table / schema / use table&lt;/td&gt;
&lt;td&gt;DDL and table switching&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Key convention: &lt;strong&gt;entries between two flushes belong to one transaction&lt;/strong&gt;, so replay needs no extra transaction-boundary metadata.&lt;/p&gt;</description></item><item><title>Database Kernel (5): Transactions, Timestamps and GC</title><link>https://digitalitem.online/en/posts/plan-transactions-mvcc/</link><pubDate>Thu, 22 Oct 2026 10:25:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-transactions-mvcc/</guid><description>&lt;p&gt;Multiple versions make concurrent reads and writes possible, but versions aren&amp;rsquo;t free: &lt;strong&gt;who creates them, who can see them, and when they can be dropped&lt;/strong&gt; all need explicit answers.&lt;/p&gt;
&lt;p&gt;Part five of the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; series.&lt;/p&gt;
&lt;h2 id="1-txnmgr-holds-very-little"&gt;1. TxnMgr holds very little&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;TxnMgr&lt;/span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;currentStartTs&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;uint64&lt;/span&gt; &lt;span style="color:#75715e"&gt;// starts at 2, +1 per txn, &amp;lt; 2^62&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;currentTxnId&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;uint64&lt;/span&gt; &lt;span style="color:#75715e"&gt;// starts at 2^62, +1 per txn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;lowestActiveId&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;uint64&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;lowestActiveStart&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;uint64&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;activeTxns&lt;/span&gt; []&lt;span style="color:#a6e22e"&gt;Txn&lt;/span&gt; &lt;span style="color:#75715e"&gt;// created, not committed/rolled back&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;committedTxns&lt;/span&gt; []&lt;span style="color:#a6e22e"&gt;Txn&lt;/span&gt; &lt;span style="color:#75715e"&gt;// committed, not GC&amp;#39;d&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;oldTxns&lt;/span&gt; []&lt;span style="color:#a6e22e"&gt;Txn&lt;/span&gt; &lt;span style="color:#75715e"&gt;// GC-able, not GC&amp;#39;d&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The two counters start in different ranges so &lt;strong&gt;timestamps and transaction ids never collide&lt;/strong&gt;:&lt;/p&gt;</description></item><item><title>Database Kernel (4): Storage — Row Groups, Column Segments and Four Layers</title><link>https://digitalitem.online/en/posts/plan-storage-layout/</link><pubDate>Thu, 22 Oct 2026 10:20:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-storage-layout/</guid><description>&lt;p&gt;Execution deals in chunks; storage answers a different question: &lt;strong&gt;where those chunks live, at what granularity, and how updates and versions fit in&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Part four of the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; series: the four-layer in-memory layout.&lt;/p&gt;
&lt;h2 id="1-four-layers"&gt;1. Four layers&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;table
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;└── row group (122,880 rows)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; └── column data (one column)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; └── column segment (256 KB block, up to 60 vectors)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; └── vector (2,048 rows)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The numbers are aligned on purpose:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;60 × 2,048 = 122,880&lt;/code&gt; — one row group is exactly 60 full vectors;&lt;/li&gt;
&lt;li&gt;a segment holds up to 60 vectors, about 256 KB;&lt;/li&gt;
&lt;li&gt;a vector is the smallest read/write unit and the executor&amp;rsquo;s batch size.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Alignment pays off&lt;/strong&gt;: scans skip whole segments and read whole vectors, with no cross-block stitching.&lt;/p&gt;</description></item><item><title>Database Kernel (3): Execution — Vectors, Chunks and the Vectorized Volcano Model</title><link>https://digitalitem.online/en/posts/plan-vector-execution/</link><pubDate>Thu, 22 Oct 2026 10:15:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-vector-execution/</guid><description>&lt;p&gt;The plan tree settles &lt;em&gt;what&lt;/em&gt; to do; execution settles &lt;em&gt;how to do it batch by batch&lt;/em&gt;. The key here isn&amp;rsquo;t the algorithm — it&amp;rsquo;s &lt;strong&gt;memory layout&lt;/strong&gt;: the same data arranged differently can be an order of magnitude faster.&lt;/p&gt;
&lt;p&gt;Part three of the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; series.&lt;/p&gt;
&lt;h2 id="1-vector-logically-an-array-physically-maybe-not"&gt;1. vector: logically an array, physically maybe not&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;vector&lt;/code&gt; is logically a fixed-size array, but it has several physical representations:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Representation&lt;/th&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;th&gt;Stores&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FLAT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;default&lt;/td&gt;
&lt;td&gt;contiguous array, same as logical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CONSTANT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;whole column identical&lt;/td&gt;
&lt;td&gt;one value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DICTIONARY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;low-cardinality strings&lt;/td&gt;
&lt;td&gt;indices + dictionary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SEQUENCE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;increasing sequence&lt;/td&gt;
&lt;td&gt;base + increment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;UNIFIED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;generic algorithms&lt;/td&gt;
&lt;td&gt;contiguous data + selection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Why so many? Because many columns during execution are constant or repetitive:&lt;/p&gt;</description></item><item><title>Database Kernel (2): From Syntax Tree to Plan Tree — Filter Pushdown and Join Ordering</title><link>https://digitalitem.online/en/posts/plan-query-planning/</link><pubDate>Thu, 22 Oct 2026 10:10:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-query-planning/</guid><description>&lt;p&gt;Bind produces scopes and expressions; execution needs a &lt;strong&gt;plan tree&lt;/strong&gt;. The conversion in between decides whether a query merely runs or runs fast.&lt;/p&gt;
&lt;p&gt;This is part two of the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; series: how the plan tree is built, and the two optimizations that matter most.&lt;/p&gt;
&lt;h2 id="1-the-minimal-plan-node"&gt;1. The minimal plan node&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;type&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;LogicalOperator&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;struct&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;Typ&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;LOT&lt;/span&gt; &lt;span style="color:#75715e"&gt;// scan / filter / project / join / agg / order / limit&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;Children&lt;/span&gt; []&lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;LogicalOperator&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// node-specific extra fields&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Generation follows the bind order:&lt;/p&gt;</description></item><item><title>Database Kernel (1): Bind Is Semantic Analysis, Not Syntax Checking</title><link>https://digitalitem.online/en/posts/plan-bind-and-cte/</link><pubDate>Thu, 22 Oct 2026 10:05:00 +0000</pubDate><guid>https://digitalitem.online/en/posts/plan-bind-and-cte/</guid><description>&lt;p&gt;People often assume SQL parsing means &amp;ldquo;turn the string into a tree&amp;rdquo; and then execution can start. The step in between — &lt;strong&gt;bind&lt;/strong&gt; — is the most underrated: it decides which table and column every name refers to, in which scope.&lt;/p&gt;
&lt;p&gt;This is the first post in the &lt;a href="https://github.com/daviszhen/plan"&gt;plan&lt;/a&gt; implementation series: what bind does, and why the order matters.&lt;/p&gt;
&lt;h2 id="1-four-components"&gt;1. Four components&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Builder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The driver for semantic analysis, one per select; also holds partial results&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;BindContext&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A scope: which relations are visible here; scopes nest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Binding&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The definition of a relation (table or subquery) and its columns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Expr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Everything except relations becomes an expression&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The key design is &lt;strong&gt;nested BindContexts&lt;/strong&gt;: a subquery isn&amp;rsquo;t &amp;ldquo;a new parser&amp;rdquo;, it&amp;rsquo;s a new scope on top of the parent. Name lookup walks up until it finds something or errors.&lt;/p&gt;</description></item></channel></rss>