<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Bohu&#39;s Blog</title>
  
  
  <link href="/atom.xml" rel="self"/>
  
  <link href="https://bohutang.me/"/>
  <updated>2026-07-03T11:49:30.844Z</updated>
  <id>https://bohutang.me/</id>
  
  <author>
    <name>BohuTANG</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>Snowtree: Review-Driven Safe AI Coding</title>
    <link href="https://bohutang.me/2026/01/10/snowtree-review-driven-safe-ai-coding/"/>
    <id>https://bohutang.me/2026/01/10/snowtree-review-driven-safe-ai-coding/</id>
    <published>2026-01-10T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<h2 id="The-Fear-of-AI-Coding"><a href="#The-Fear-of-AI-Coding" class="headerlink" title="The Fear of AI Coding"></a>The Fear of AI Coding</h2><p>Building complex projects with AI coding agents requires multiple rounds of conversation and iteration.</p><p><strong>What scares you?</strong></p><ul><li>Round 1: The AI changes 30 files, 300 modifications. You get exhausted reviewing by the 50th change.</li><li>Round 2: You ask the AI to continue, and it rewrites the code you just reviewed.</li><li>Round 3: The latest changes break the logic. You want to revert to the last “good” state, but there’s no reliable checkpoint.</li><li>Round N: The codebase is in chaos, spiraling out of your control.</li></ul><p><strong>The core pain point</strong>: In multi-round iterations, AI can write code, but you don’t know how to take over safely and efficiently.</p><p>Existing AI IDEs offer a pile of features but give you no <strong>control</strong>.</p><p>Even worse: Code written by AI is pushed directly to teammates for review, without the owner even reading it line by line. <strong>The owner must be the first reviewer.</strong> AI is an assistant, not a replacement.</p><p>These issues became increasingly apparent during the development of <a href="https://github.com/databendlabs/databend" target="_blank" rel="noopener">Databend</a>. With nearly 1.9 million lines of Rust code and numerous modules, the usage of AI coding agents is skyrocketing. Letting AI change things at will? Unimaginable. Restricting it too much? Slows down iteration.</p><p>We need to find a balance between <strong>pure vibe coding</strong> (letting AI write freely) and <strong>traditional coding</strong> (hand-written): AI assists powerfully, humans control strictly, ensuring code quality matches human standards.</p><p>“If a workman wishes to do a good job, he must first sharpen his tools.” So, I developed <a href="https://github.com/bohutang/snowtree" target="_blank" rel="noopener">Snowtree</a>: <strong>To let you trust AI with your code.</strong></p><p>Snowtree is a desktop application that manages multiple AI coding agent sessions. It uses worktree isolation + incremental review to put you back in control of AI-generated code.</p><p>It solves three core problems: isolating git code to reduce interference, keeping AI agent capabilities up-to-date, and safe handover during multi-round iterations.</p><p><img src="/images/posts/snowtree-show.gif" alt="Snowtree"></p><h2 id="What-Does-Snowtree-Do"><a href="#What-Does-Snowtree-Do" class="headerlink" title="What Does Snowtree Do?"></a>What Does Snowtree Do?</h2><p>In one sentence: <strong>A complete loop from isolated environment to PR</strong>.</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">┌─────────────┐     ┌─────────────┐     ┌─────────────┐</span><br><span class="line">│  Worktree   │────▶│  AI Coding  │────▶│   Changes   │</span><br><span class="line">│  Isolation  │     │ Codex&#x2F;Claude│     │ Code Diffs  │</span><br><span class="line">└─────────────┘     └─────────────┘     └─────────────┘</span><br><span class="line">                                               │</span><br><span class="line">       ┌───────────────────────────────────────┘</span><br><span class="line">       ▼</span><br><span class="line">┌─────────────┐     ┌─────────────┐     ┌─────────────┐</span><br><span class="line">│   Review    │────▶│Stage&#x2F;Restore│────▶│   Commit    │</span><br><span class="line">│ Line-by-Line│     │ Keep&#x2F;Discard│     │  Snapshot   │</span><br><span class="line">└─────────────┘     └─────────────┘     └─────────────┘</span><br><span class="line">                                               │</span><br><span class="line">                                               ▼</span><br><span class="line">                                        ┌─────────────┐</span><br><span class="line">                                        │  Create&#x2F;    │</span><br><span class="line">                                        │  Sync PR    │</span><br><span class="line">                                        └─────────────┘</span><br></pre></td></tr></table></figure><p><strong>The Complete Workflow</strong>:</p><ol><li><strong>Worktree Isolation</strong>: Create an independent git worktree for each AI session, zero interference with the main repo</li><li><strong>AI Coding</strong>: Invoke Codex or Claude Code CLI in the isolated environment</li><li><strong>Changes Generated</strong>: After AI completes, all code changes are displayed automatically</li><li><strong>Line-by-Line Review</strong>: Review each hunk to see exactly what AI changed</li><li><strong>Stage or Restore</strong>: Stage hunks you approve, Restore (discard) ones you don’t</li><li><strong>Commit</strong>: Commit staged code to create a trusted snapshot</li><li><strong>Create/Sync PR</strong>: One-click to create or sync to a remote PR</li></ol><p>This is Snowtree’s core value: <strong>Pipeline AI’s free creativity with human’s strict control</strong>.</p><h2 id="Three-Core-Design-Philosophies"><a href="#Three-Core-Design-Philosophies" class="headerlink" title="Three Core Design Philosophies"></a>Three Core Design Philosophies</h2><h3 id="1-Parallel-Isolation-Based-on-Git-Worktree"><a href="#1-Parallel-Isolation-Based-on-Git-Worktree" class="headerlink" title="1. Parallel Isolation Based on Git Worktree"></a>1. Parallel Isolation Based on Git Worktree</h3><p>We are used to git branches, but you can only develop on one branch at a time.</p><p>Imagine this: Codex is refactoring a module when a critical bug report comes in. Stop and wait for the AI? Or commit and switch branches?</p><p><strong>The Snowtree Solution</strong>: A separate worktree for each AI session.</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">main-repo&#x2F;</span><br><span class="line">├── .git&#x2F;</span><br><span class="line">├── src&#x2F;</span><br><span class="line">└── ...</span><br><span class="line"></span><br><span class="line">~&#x2F;.snowtree&#x2F;worktrees&#x2F;</span><br><span class="line">├── session-1-refactor&#x2F;         # Codex is refactoring a module</span><br><span class="line">├── session-2-bugfix&#x2F;           # Claude is fixing a critical bug</span><br><span class="line">└── session-3-feature&#x2F;          # Another AI agent developing a new feature</span><br></pre></td></tr></table></figure><p><img src="/images/posts/snowtree-chat.png" alt="Snowtree Chat"></p><p>Completely isolated, no interference. AI can change whatever it wants without affecting your main workspace or clashing with other sessions. When done, merge and delete the worktree. Clean and simple.</p><h3 id="2-Native-AI-Coding-Agent-Capabilities-No-Wrappers"><a href="#2-Native-AI-Coding-Agent-Capabilities-No-Wrappers" class="headerlink" title="2. Native AI Coding Agent Capabilities, No Wrappers"></a>2. Native AI Coding Agent Capabilities, No Wrappers</h3><p>Many AI IDEs wrap or “improve” AI coding agents, resulting in:</p><ul><li>Always lagging behind the official versions (Claude Code and Codex update frequently and know best how to adapt to their models).</li><li>Missing out on the latest features.</li><li>Custom implementations that are worse than the original.</li></ul><p><strong>Philosophy</strong>: Maximize the use of native CLIs, zero encapsulation.</p><p>Directly invoke the local Claude Code and Codex CLIs, launching real processes via PTY, capturing output without altering behavior.</p><p>Do one thing only: <strong>Manage sessions and workflows</strong>, don’t reinvent the AI coding agent.</p><h3 id="3-Humans-Must-Control-AI-Code-Review-Stage-Commit-Workflow"><a href="#3-Humans-Must-Control-AI-Code-Review-Stage-Commit-Workflow" class="headerlink" title="3. Humans Must Control AI Code: Review-Stage-Commit Workflow"></a>3. Humans Must Control AI Code: Review-Stage-Commit Workflow</h3><p>The core of the core.</p><p><strong>My practical experience</strong>: After every round of conversation, if it looks good, commit immediately to prevent the next round of AI changes from breaking things without a way back.</p><p>This is essentially an <strong>incremental snapshot approach</strong>: stage what you confirm immediately, and only review the new changes each time.</p><p><strong>Traditional Workflow</strong>:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">AI modifies code → Review everything at once → commit</span><br><span class="line">                        ↓</span><br><span class="line">            Too much, can&#39;t handle the review</span><br></pre></td></tr></table></figure><p><strong>Snowtree Workflow</strong>: Incremental review + snapshot</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Round 1: AI modifies code → Review → Approve → Stage (snapshot)</span><br><span class="line">                                                ↓</span><br><span class="line">Round 2: AI continues → Review only increments → Approve → Stage</span><br><span class="line">                                                ↓</span><br><span class="line">Round N: Repeat...  → All passed → Commit → Create&#x2F;Push PR</span><br></pre></td></tr></table></figure><p><img src="/images/posts/snowtree-diff-review.png" alt="Snowtree Diff Review"></p><p>Core: <strong>Stage = Snapshot</strong>.</p><p>Code that is Approved is staged immediately, saved in the staging area. The AI can continue to modify freely, and I only review the new increments. You can even commit midway and sync to a GitHub PR. Foolproof.</p><p>Key Advantages:</p><ul><li><strong>Batch Review</strong>: Review a few files at a time, don’t get overwhelmed.</li><li><strong>Line-by-Line Control</strong>: Don’t stage code you don’t like; continue the conversation and have the AI rewrite it.</li><li><strong>Safe Iteration</strong>: staged = snapshot. No matter how the AI changes things later, previous work is safe.</li></ul><h2 id="Who-is-this-for"><a href="#Who-is-this-for" class="headerlink" title="Who is this for?"></a>Who is this for?</h2><p>Developers who are experienced and want to seriously review AI code.</p><h2 id="Open-Source"><a href="#Open-Source" class="headerlink" title="Open Source"></a>Open Source</h2><p>Project URL: <a href="https://github.com/bohutang/snowtree" target="_blank" rel="noopener">https://github.com/bohutang/snowtree</a> (Apache 2.0)</p><p>Core: <strong>Minimalist, Native, Controllable</strong>.</p><hr><p><em>Inspired by the design style of excellent IDEs like Zed/OpenCode, based on their code, distilled alternately by Codex and Claude Code, combined with my product philosophy.</em></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;The-Fear-of-AI-Coding&quot;&gt;&lt;a href=&quot;#The-Fear-of-AI-Coding&quot; class=&quot;headerlink&quot; title=&quot;The Fear of AI Coding&quot;&gt;&lt;/a&gt;The Fear of AI Coding&lt;/
      
    
    </summary>
    
    
      <category term="Engineering" scheme="https://bohutang.me/categories/Engineering/"/>
    
    
      <category term="AI" scheme="https://bohutang.me/tags/AI/"/>
    
      <category term="IDE" scheme="https://bohutang.me/tags/IDE/"/>
    
      <category term="Developer Tools" scheme="https://bohutang.me/tags/Developer-Tools/"/>
    
      <category term="Git" scheme="https://bohutang.me/tags/Git/"/>
    
      <category term="Workflow" scheme="https://bohutang.me/tags/Workflow/"/>
    
  </entry>
  
  <entry>
    <title>Snowtree：通过 Review 驱动让 AI 代码安全可控</title>
    <link href="https://bohutang.me/2026/01/10/snowtree-review-driven-safe-ai-coding/"/>
    <id>https://bohutang.me/2026/01/10/snowtree-review-driven-safe-ai-coding/</id>
    <published>2026-01-10T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<h2 id="AI-写代码的恐惧"><a href="#AI-写代码的恐惧" class="headerlink" title="AI 写代码的恐惧"></a>AI 写代码的恐惧</h2><p>用 AI coding agent 构建复杂项目，需要多轮对话、反复迭代。</p><p><strong>你会害怕什么？</strong></p><ul><li>第 1 轮：AI 改了 30 个文件，300 处修改，review 到第 50 处就崩溃</li><li>第 2 轮：继续让 AI 改，它把刚 review 过的代码又改了</li><li>第 3 轮：最新改动破坏了逻辑，想回退到上一个好状态，但没有可信的 checkpoint</li><li>第 N 轮：代码处于混乱状态，越来越超出你的控制</li></ul><p><strong>核心痛点</strong>：多轮迭代中，AI 能写代码，但你不知道如何安全、高效地接管。</p><p>现有 AI IDE 给了一堆功能，没给你<strong>控制权</strong>。</p><p>更糟的是：AI 写的代码直接推给队友 review，owner 自己都没逐行看过。<strong>Owner 必须是第一个 reviewer。</strong> AI 是辅助工具，不是替代品。</p><p>这些问题在 <a href="https://github.com/databendlabs/databend" target="_blank" rel="noopener">Databend</a> 开发中越来越明显。近 190 万行 Rust 代码，模块众多，AI coding agent 使用率越来越高。放手让 AI 随便改？不敢想象。限制太死？拖慢迭代速度。</p><p>需要在<strong>完全 vibe coding</strong>（AI 随便写）和<strong>传统 coding</strong>（纯手写）之间找到平衡：AI 强力辅助，人严格把控，代码质量像人写的。</p><p>工欲善其事，必先利其器。于是我开发了 <a href="https://github.com/bohutang/snowtree" target="_blank" rel="noopener">Snowtree</a>：<strong>让你敢放心地让 AI 写代码。</strong></p><p>Snowtree 是一个桌面应用，管理多个 AI coding agent 会话，通过 worktree 隔离 + 增量 review 让你掌控 AI 代码。</p><p>它解决三个核心问题：隔离 git 代码减少干扰、保持 AI agent 最新能力、多轮迭代的安全接管。</p><p><img src="/images/posts/snowtree-show.gif" alt="Snowtree"></p><h2 id="Snowtree-做什么？"><a href="#Snowtree-做什么？" class="headerlink" title="Snowtree 做什么？"></a>Snowtree 做什么？</h2><p>一句话：<strong>从隔离环境到 PR，完整闭环</strong>。</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">┌─────────────┐     ┌─────────────┐     ┌─────────────┐</span><br><span class="line">│  Worktree   │────▶│  AI Coding  │────▶│   Changes   │</span><br><span class="line">│   隔离环境   │     │ Codex&#x2F;Claude│     │   代码变更   │</span><br><span class="line">└─────────────┘     └─────────────┘     └─────────────┘</span><br><span class="line">                                               │</span><br><span class="line">       ┌───────────────────────────────────────┘</span><br><span class="line">       ▼</span><br><span class="line">┌─────────────┐     ┌─────────────┐     ┌─────────────┐</span><br><span class="line">│   Review    │────▶│Stage&#x2F;Restore│────▶│   Commit    │</span><br><span class="line">│   逐行审查   │     │  选择保留    │     │   提交快照   │</span><br><span class="line">└─────────────┘     └─────────────┘     └─────────────┘</span><br><span class="line">                                               │</span><br><span class="line">                                               ▼</span><br><span class="line">                                        ┌─────────────┐</span><br><span class="line">                                        │  Create&#x2F;    │</span><br><span class="line">                                        │  Sync PR    │</span><br><span class="line">                                        └─────────────┘</span><br></pre></td></tr></table></figure><p><strong>完整工作流</strong>：</p><ol><li><strong>Worktree 隔离</strong>：为每个 AI 会话创建独立的 git worktree，主仓库零干扰</li><li><strong>AI Coding</strong>：在隔离环境中调用 Codex 或 Claude Code CLI 进行编码</li><li><strong>Changes 生成</strong>：AI 完成后，自动展示所有代码变更</li><li><strong>逐行 Review</strong>：按 hunk 逐行审查，看清 AI 改了什么</li><li><strong>Stage or Restore</strong>：满意的 hunk 点 Stage 保留，不满意的 Restore 丢弃</li><li><strong>Commit</strong>：将 staged 的代码提交，形成可信快照</li><li><strong>Create/Sync PR</strong>：基于 commit 一键创建或同步到远程 PR</li></ol><p>这就是 Snowtree 的核心价值：<strong>把 AI 的自由发挥和人的严格把控串成一条流水线</strong>。</p><h2 id="三个核心设计理念"><a href="#三个核心设计理念" class="headerlink" title="三个核心设计理念"></a>三个核心设计理念</h2><h3 id="1-基于-Git-Worktree-的并行隔离"><a href="#1-基于-Git-Worktree-的并行隔离" class="headerlink" title="1. 基于 Git Worktree 的并行隔离"></a>1. 基于 Git Worktree 的并行隔离</h3><p>习惯用 git branch，但同一时刻只能开发一个分支。</p><p>想象这个场景：Codex 正在重构模块，突然来了紧急 bug。停下来等 AI 完成？还是先 commit 再切 branch？</p><p><strong>Snowtree 方案</strong>：每个 AI 会话独立的 worktree。</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">main-repo&#x2F;</span><br><span class="line">├── .git&#x2F;</span><br><span class="line">├── src&#x2F;</span><br><span class="line">└── ...</span><br><span class="line"></span><br><span class="line">~&#x2F;.snowtree&#x2F;worktrees&#x2F;</span><br><span class="line">├── session-1-refactor&#x2F;         # Codex 在重构模块</span><br><span class="line">├── session-2-bugfix&#x2F;           # Claude 在修紧急 bug</span><br><span class="line">└── session-3-feature&#x2F;          # 另一个 AI coding agent 开发新功能</span><br></pre></td></tr></table></figure><p><img src="/images/posts/snowtree-chat.png" alt="Snowtree Chat"></p><p>完全隔离，互不干扰。AI 随便改，不影响主工作区，不和其他会话冲突。完成后合并、删除 worktree，干净利落。</p><h3 id="2-原生-AI-Coding-Agent-能力，不做封装"><a href="#2-原生-AI-Coding-Agent-能力，不做封装" class="headerlink" title="2. 原生 AI Coding Agent 能力，不做封装"></a>2. 原生 AI Coding Agent 能力，不做封装</h3><p>很多 AI IDE 封装或”改进” AI coding agent，结果：</p><ul><li>永远落后于官方（Claude Code 和 Codex 更新频繁，最清楚如何适配自己的模型）</li><li>最新特性用不上</li><li>自己实现的还不如原版</li></ul><p><strong>哲学</strong>：最大化利用原生 CLI，零封装。</p><p>直接调用本机的 Claude Code 和 Codex CLI，通过 PTY 启动真实进程，捕获输出，不改行为。</p><p>只做一件事：<strong>管理会话和工作流</strong>，不重新发明 AI coding agent。</p><h3 id="3-人必须掌控-AI-代码：Review-Stage-Commit-工作流"><a href="#3-人必须掌控-AI-代码：Review-Stage-Commit-工作流" class="headerlink" title="3. 人必须掌控 AI 代码：Review-Stage-Commit 工作流"></a>3. 人必须掌控 AI 代码：Review-Stage-Commit 工作流</h3><p>核心中的核心。</p><p><strong>我的实战经验</strong>：每轮对话后，觉得可以就赶紧 commit，防止下轮 AI 改动破坏又无法回退。</p><p>这其实就是<strong>增量 snapshot 思路</strong>：确认的立刻保存（stage），每次只 review 新增改动。</p><p><strong>传统工作流</strong>：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">AI 改代码 → 一次性 review 全部 → commit</span><br><span class="line">                 ↓</span><br><span class="line">            太多，review 不过来</span><br></pre></td></tr></table></figure><p><strong>Snowtree 工作流</strong>：增量 review + snapshot</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Round 1: AI 改代码 → Review → Approve → Stage (snapshot)</span><br><span class="line">                                           ↓</span><br><span class="line">Round 2: AI 继续改 → 只 review 增量 → Approve → Stage</span><br><span class="line">                                           ↓</span><br><span class="line">Round N: 重复...  → 全部通过 → Commit → Create&#x2F;Push PR</span><br></pre></td></tr></table></figure><p><img src="/images/posts/snowtree-diff-review.png" alt="Snowtree Diff Review"></p><p>核心：<strong>Stage = Snapshot</strong>。</p><p>Approve 的代码立刻 stage，保存在 staging area。AI 随便继续改，我只 review 新增量。甚至可以中途 commit，sync 到 GitHub PR，万无一失。</p><p>核心优势：</p><ul><li><strong>分批 review</strong>：每次看几个文件，不被淹没</li><li><strong>按行控制</strong>：不爽的代码不做 stage，继续对话让 AI 重改</li><li><strong>安全迭代</strong>：staged = snapshot，AI 怎么改都不影响</li></ul><h2 id="适合谁？"><a href="#适合谁？" class="headerlink" title="适合谁？"></a>适合谁？</h2><p>有经验、想认真 review AI 代码的开发者。</p><h2 id="开源"><a href="#开源" class="headerlink" title="开源"></a>开源</h2><p>项目地址：<a href="https://github.com/bohutang/snowtree" target="_blank" rel="noopener">https://github.com/bohutang/snowtree</a> (Apache 2.0)</p><p>核心：<strong>极简、原生、可控</strong>。</p><hr><p><em>参考了 Zed/OpenCode 等优秀 IDE 的设计风格，基于他们的代码，由 Codex 和 Claude Code 交替蒸馏，加上我的产品观。</em></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;AI-写代码的恐惧&quot;&gt;&lt;a href=&quot;#AI-写代码的恐惧&quot; class=&quot;headerlink&quot; title=&quot;AI 写代码的恐惧&quot;&gt;&lt;/a&gt;AI 写代码的恐惧&lt;/h2&gt;&lt;p&gt;用 AI coding agent 构建复杂项目，需要多轮对话、反复迭代。&lt;/p&gt;

      
    
    </summary>
    
    
      <category term="Engineering" scheme="https://bohutang.me/categories/Engineering/"/>
    
    
      <category term="AI" scheme="https://bohutang.me/tags/AI/"/>
    
      <category term="IDE" scheme="https://bohutang.me/tags/IDE/"/>
    
      <category term="Developer Tools" scheme="https://bohutang.me/tags/Developer-Tools/"/>
    
      <category term="Git" scheme="https://bohutang.me/tags/Git/"/>
    
      <category term="Workflow" scheme="https://bohutang.me/tags/Workflow/"/>
    
  </entry>
  
  <entry>
    <title>2025 -&gt; 2026</title>
    <link href="https://bohutang.me/2025/12/31/2025-year-in-review/"/>
    <id>https://bohutang.me/2025/12/31/2025-year-in-review/</id>
    <published>2025-12-31T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<p>For me, 2025 was about one main thing: using AI to accelerate the development efficiency of the <a href="https://github.com/databendlabs/databend" target="_blank" rel="noopener">Databend</a> team.</p><h2 id="AI"><a href="#AI" class="headerlink" title="AI"></a>AI</h2><p>I built testing and support systems with AI, using them to locate customer issues faster.</p><p>I tried many models, but ended up with just two on my desktop:</p><ul><li>Codex (gpt-5.2)</li><li>Claude Code (Opus 4.5)</li></ul><p>They handled most of the heavy lifting: analyzing logs, reproducing bugs, writing glue code, and fixing issues.</p><p>Yes — all the systems listed below were built with AI assistance.</p><h2 id="The-Unsolved-Problem-Determinism"><a href="#The-Unsolved-Problem-Determinism" class="headerlink" title="The Unsolved Problem: Determinism"></a>The Unsolved Problem: Determinism</h2><p>One problem remains unsolved: testability and correctness.</p><p>When a system undergoes multiple rounds of AI-driven modifications, each round adds a bit of uncertainty. After enough rounds, while delivery speed increases, trust decreases.</p><p>How do we maximize determinism? I still don’t have a good answer. Hopefully 2026 will bring tools to solve this.</p><h2 id="Systems-Built-in-2025-Vibe-Engineering"><a href="#Systems-Built-in-2025-Vibe-Engineering" class="headerlink" title="Systems Built in 2025 (Vibe Engineering)"></a>Systems Built in 2025 (Vibe Engineering)</h2><p>So what did I build this year?</p><h3 id="Top1-Databend-Testing-System"><a href="#Top1-Databend-Testing-System" class="headerlink" title="Top1: Databend Testing System"></a>Top1: Databend Testing System</h3><p>The Databend testing system: comparing performance and functionality against other top-tier data warehouses to catch regressions early.</p><a href="/images/posts/2025-databend-testing-system.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-databend-testing-system.png" alt="Databend testing system" loading="lazy" decoding="async" /></a><h3 id="Top2-databend-com"><a href="#Top2-databend-com" class="headerlink" title="Top2: databend.com"></a>Top2: <a href="https://databend.com" target="_blank" rel="noopener">databend.com</a></h3><p>The official website. Fast, clear, real-time updates.</p><a href="/images/posts/2025-databend-com.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-databend-com.png" alt="databend.com" loading="lazy" decoding="async" /></a><h3 id="Top3-Public-S3-Bucket-s3-databend-cloud"><a href="#Top3-Public-S3-Bucket-s3-databend-cloud" class="headerlink" title="Top3: Public S3 Bucket s3.databend.cloud"></a>Top3: Public S3 Bucket <a href="https://s3.databend.cloud" target="_blank" rel="noopener">s3.databend.cloud</a></h3><p>A public bucket for sharing build artifacts and files.</p><a href="/images/posts/2025-s3-databend-cloud.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-s3-databend-cloud.png" alt="s3.databend.cloud" loading="lazy" decoding="async" /></a><h3 id="Top4-Unified-Key-Management-for-Codex-Claude-Code-Gemini"><a href="#Top4-Unified-Key-Management-for-Codex-Claude-Code-Gemini" class="headerlink" title="Top4: Unified Key Management for Codex / Claude Code / Gemini"></a>Top4: Unified Key Management for Codex / Claude Code / Gemini</h3><p>Unified account and key management: one API key, multiple providers, multiple upstream keys for failover. Greatly simplified integration and daily use.</p><a href="/images/posts/2025-ai-key-management.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-ai-key-management.png" alt="Unified AI key management" loading="lazy" decoding="async" /></a><h2 id="2026"><a href="#2026" class="headerlink" title="2026"></a>2026</h2><p>My biggest wish remains unchanged: bring more determinism to AI-assisted engineering.</p><p>If we can systematically solve correctness, testability, and regression detection, the speed ceiling can be raised another level.</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;For me, 2025 was about one main thing: using AI to accelerate the development efficiency of the &lt;a href=&quot;https://github.com/databendlabs/
      
    
    </summary>
    
    
    
      <category term="2025" scheme="https://bohutang.me/tags/2025/"/>
    
      <category term="year-in-review" scheme="https://bohutang.me/tags/year-in-review/"/>
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="ai" scheme="https://bohutang.me/tags/ai/"/>
    
  </entry>
  
  <entry>
    <title>2025 -&gt; 2026</title>
    <link href="https://bohutang.me/2025/12/31/2025-year-in-review/"/>
    <id>https://bohutang.me/2025/12/31/2025-year-in-review/</id>
    <published>2025-12-31T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<p>2025年对我来说，主要做了一件事：用 AI 加速 <a href="https://github.com/databendlabs/databend" target="_blank" rel="noopener">Databend</a> 团队的开发效率。</p><h2 id="AI"><a href="#AI" class="headerlink" title="AI"></a>AI</h2><p>我用 AI 构建测试和辅助系统，并用它来更快地定位客户问题。</p><p>试了很多模型，最后桌面上只留了两个：</p><ul><li>Codex (gpt-5.2)</li><li>Claude Code (Opus 4.5)</li></ul><p>它们承担了大部分重活：分析日志、复现问题、写胶水代码、修复 bug。</p><p>是的——下面列出的所有系统都是在 AI 的辅助下完成的。</p><h2 id="未解决的问题：确定性"><a href="#未解决的问题：确定性" class="headerlink" title="未解决的问题：确定性"></a>未解决的问题：确定性</h2><p>有一个问题始终没有解决：可测试性和正确性。</p><p>当一个系统经历多轮 AI 驱动的修改后，每一轮都会增加一点不确定性。轮次多了，虽然交付速度更快了，但信任度却下降了。</p><p>如何最大化确定性？目前还没有好的答案。希望 2026 年能出现解决这个问题的工具。</p><h2 id="2025-年构建的系统（氛围编程）"><a href="#2025-年构建的系统（氛围编程）" class="headerlink" title="2025 年构建的系统（氛围编程）"></a>2025 年构建的系统（氛围编程）</h2><p>好吧，今年都做了什么？</p><h3 id="Top1-Databend-测试系统"><a href="#Top1-Databend-测试系统" class="headerlink" title="Top1: Databend 测试系统"></a>Top1: Databend 测试系统</h3><p>Databend 测试系统：与其他顶级数仓进行性能和功能对比，及早发现回归问题。</p><a href="/images/posts/2025-databend-testing-system.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-databend-testing-system.png" alt="Databend testing system" loading="lazy" decoding="async" /></a><h3 id="Top2-databend-com"><a href="#Top2-databend-com" class="headerlink" title="Top2: databend.com"></a>Top2: <a href="https://databend.com" target="_blank" rel="noopener">databend.com</a></h3><p>官方网站。快速、清晰、实时更新。</p><a href="/images/posts/2025-databend-com.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-databend-com.png" alt="databend.com" loading="lazy" decoding="async" /></a><h3 id="Top3-公共-S3-存储桶-s3-databend-cloud"><a href="#Top3-公共-S3-存储桶-s3-databend-cloud" class="headerlink" title="Top3: 公共 S3 存储桶 s3.databend.cloud"></a>Top3: 公共 S3 存储桶 <a href="https://s3.databend.cloud" target="_blank" rel="noopener">s3.databend.cloud</a></h3><p>用于共享构建产物和文件的公共存储桶。</p><a href="/images/posts/2025-s3-databend-cloud.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-s3-databend-cloud.png" alt="s3.databend.cloud" loading="lazy" decoding="async" /></a><h3 id="Top4-Codex-Claude-Code-Gemini-统一密钥管理"><a href="#Top4-Codex-Claude-Code-Gemini-统一密钥管理" class="headerlink" title="Top4: Codex / Claude Code / Gemini 统一密钥管理"></a>Top4: Codex / Claude Code / Gemini 统一密钥管理</h3><p>统一的账号和密钥管理：一个 API key，多个服务商，多个上游密钥用于故障转移。极大地简化了集成和日常使用。</p><a href="/images/posts/2025-ai-key-management.png" target="_blank" rel="noopener">  <img class="tweet-img" src="/images/posts/2025-ai-key-management.png" alt="Unified AI key management" loading="lazy" decoding="async" /></a><h2 id="2026"><a href="#2026" class="headerlink" title="2026"></a>2026</h2><p>我最大的愿望依然不变：为 AI 辅助工程带来更多确定性。</p><p>如果我们能系统性地解决正确性、可测试性和回归检测问题，速度的天花板还能再提升一个档次。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;2025年对我来说，主要做了一件事：用 AI 加速 &lt;a href=&quot;https://github.com/databendlabs/databend&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Databend&lt;/a&gt; 团队的开发效率。&lt;/p&gt;
&lt;h2
      
    
    </summary>
    
    
    
      <category term="2025" scheme="https://bohutang.me/tags/2025/"/>
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="ai" scheme="https://bohutang.me/tags/ai/"/>
    
      <category term="年度总结" scheme="https://bohutang.me/tags/%E5%B9%B4%E5%BA%A6%E6%80%BB%E7%BB%93/"/>
    
  </entry>
  
  <entry>
    <title>2023 -&gt; 2024</title>
    <link href="https://bohutang.me/2023/12/29/bohu-2023/"/>
    <id>https://bohutang.me/2023/12/29/bohu-2023/</id>
    <published>2023-12-29T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<p>This blog post was written <strong>standing up</strong>, without AI assistance — human-native!</p><h2 id="AI"><a href="#AI" class="headerlink" title="AI"></a>AI</h2><p>Since GPT-4 arrived, I can easily switch between database kernel engineer, test engineer, and documentation engineer roles. It’s like gaining superpowers. I’ve also started helping people around me make better use of AI. I really hope to build something meaningful with open-source LLMs in 2024.</p><h2 id="Code"><a href="#Code" class="headerlink" title="Code"></a>Code</h2><p>In 2023, I continued contributing heavily to <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a>. Although I wrote less code compared to 2022, this year’s work was more practical. Every time I code, I feel an incredible sense of warmth and purpose. It makes me love the profession of “programmer” more and more: with just a laptop, you can change the world.</p><h2 id="Fitness"><a href="#Fitness" class="headerlink" title="Fitness"></a>Fitness</h2><p>In 2023, skateboarding became my primary way of staying fit. Each hour-long high-intensity session leaves me drenched in sweat, which feels amazing. I can now pull off some advanced tricks that look pretty cool. Of course, there were some accidents along the way: a broken finger, a shin hitting the wall. But I’ve recovered, and my passion for this challenging and adventurous sport remains strong.</p><h2 id="Changes"><a href="#Changes" class="headerlink" title="Changes"></a>Changes</h2><p>One major change in 2023: I switched from Ubuntu (which I’d used for over a decade) to MacOS. My setup is now much lighter. Just a MacBook, and I can work anywhere. I said goodbye to external monitors and mechanical keyboards for good.</p><h2 id="Databend"><a href="#Databend" class="headerlink" title="Databend"></a>Databend</h2><p>In 2023, all my energy still revolved around <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a>. I’m committed to making <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> truly embody the “Bring Compute to Data” philosophy and deliver greater value to users. This lays a solid foundation for achieving <a href="https://github.com/datafuselabs/databend/issues/14167" target="_blank" rel="noopener">even bigger goals</a> in 2024.</p><h2 id="2024"><a href="#2024" class="headerlink" title="2024"></a>2024</h2><p>I predict that the big data field will undergo some structural transformations in 2024, evolving into richer application scenarios. I hope <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> plays a key role in this process, continues leading the industry, and contributes to making the world a better place.</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;This blog post was written &lt;strong&gt;standing up&lt;/strong&gt;, without AI assistance — human-native!&lt;/p&gt;
&lt;h2 id=&quot;AI&quot;&gt;&lt;a href=&quot;#AI&quot; class=&quot;heade
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="2023" scheme="https://bohutang.me/tags/2023/"/>
    
  </entry>
  
  <entry>
    <title>2023 -&gt; 2024</title>
    <link href="https://bohutang.me/2023/12/29/bohu-2023/"/>
    <id>https://bohutang.me/2023/12/29/bohu-2023/</id>
    <published>2023-12-29T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<p>这篇博客是<strong>站</strong>着写的，没有借助AI，human-native！</p><h2 id="AI"><a href="#AI" class="headerlink" title="AI"></a>AI</h2><p>自从有了 GPT4，我可以在数据库内核工程师、测试工程师、文档工程师之间轻松切换，做到了如🐯添🪽。同时，也开始影响身边的人如何更好地利用AI。非常希望 2024 年能够基于开源 LLM 做一些有意义的事情。</p><h2 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h2><p>2023 年，继续为 <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> 贡献了大量代码，虽然与 2022 相比少了一些，但今年的代码更加实用。每次编码，都能感觉到无比的温暖和崇高的使命感，也使我越来越热爱“程序员”这个职业：一台电脑就可以改变世界。</p><h2 id="运动"><a href="#运动" class="headerlink" title="运动"></a>运动</h2><p>2023，滑板成为我锻炼身体的主要方式。每次一个小时的高强度训练就会让我汗流浃背，感觉非常畅快，现在可以完成一些高级且具欣赏性的动作，虽然也发生过一些意外：手指骨折，小腿骨撞墙，不过都已经恢复，对滑板这个充满挑战和冒险的运动热爱不减。</p><h2 id="改变"><a href="#改变" class="headerlink" title="改变"></a>改变</h2><p>2023 一个重大变化是，我把用了十几年的 Ubuntu 系统切到了 MacOS，使我的装备更加轻量，只需要一台 MacBook 就能随时随地完成所有工作，彻底告别了显示器和机械键键盘。</p><h2 id="Databend"><a href="#Databend" class="headerlink" title="Databend"></a>Databend</h2><p>2023年，所有精力依然围绕 <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> 展开，致力于让 <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> 更加符合 “Bring Compute to Data” 的理念，为用户带来更高的价值，这也为 2024 年实现<a href="https://github.com/datafuselabs/databend/issues/14167" target="_blank" rel="noopener">更加宏大的目标</a>打下了坚实基础。</p><h2 id="2024"><a href="#2024" class="headerlink" title="2024"></a>2024</h2><p>预测 2024 年大数据领域将会发生一些结构性的变革，并演化出更加丰富的应用场景，希望 <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend</a> 在这一进程中发挥重要作用，继续走在行业前列，为世界更加美好贡献一份力量。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;这篇博客是&lt;strong&gt;站&lt;/strong&gt;着写的，没有借助AI，human-native！&lt;/p&gt;
&lt;h2 id=&quot;AI&quot;&gt;&lt;a href=&quot;#AI&quot; class=&quot;headerlink&quot; title=&quot;AI&quot;&gt;&lt;/a&gt;AI&lt;/h2&gt;&lt;p&gt;自从有了 GPT4，我可以在数
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="2023" scheme="https://bohutang.me/tags/2023/"/>
    
  </entry>
  
  <entry>
    <title>Six Days with COVID</title>
    <link href="https://bohutang.me/2022/12/15/covid-22/"/>
    <id>https://bohutang.me/2022/12/15/covid-22/</id>
    <published>2022-12-15T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<p>Beijing gradually relaxed COVID restrictions in early December. I worked from a coffee shop for a few days, and that’s when I caught it. Today I’m mostly recovered, so here’s the full timeline.<br>It’s hard to avoid spreading it within a family. The key is timing infections so people can take care of each other.</p><h2 id="December-10-Saturday-—-Fever-starts"><a href="#December-10-Saturday-—-Fever-starts" class="headerlink" title="December 10, Saturday — Fever starts"></a>December 10, Saturday — Fever starts</h2><p>Woke up with a slightly sore throat. By afternoon, I felt chills. Temperature: 37°C. I isolated in my room and started wearing an N95.</p><p>The kids set up police tape outside my door with a “Close Contact” warning sign. They turned it into a game.</p><p>By dinner, my fever hit 38°C. Appetite was fine, but I had a killer headache. I managed to get a few rapid antigen tests. Results: negative.</p><p>By midnight, I hit 39°C. The headache was brutal. I had all sorts of weird dreams. The pain felt just like when I had a cold as a kid, and suddenly I wanted instant noodles or canned food. I checked online — canned peaches were already sold out everywhere (medicine was even harder to find!). I quickly ordered a few packs of instant noodles.</p><h2 id="December-11-Sunday-—-Fever-continues"><a href="#December-11-Sunday-—-Fever-continues" class="headerlink" title="December 11, Sunday — Fever continues"></a>December 11, Sunday — Fever continues</h2><p>The canned peaches and instant noodles still haven’t arrived!</p><p>This was the worst day. My head felt like it was splitting. Tested in the morning: strong positive. Appetite: still normal.</p><p>That night, the fever peaked above 39°C. The headache was so bad I could barely sleep. I really wanted fruit (if only those peaches had come).</p><h2 id="December-12-Monday-—-Fever-breaking"><a href="#December-12-Monday-—-Fever-breaking" class="headerlink" title="December 12, Monday — Fever breaking"></a>December 12, Monday — Fever breaking</h2><p>After a night of high fever, I woke up with a mildly sore throat. But it wasn’t that “razor blades in the throat” sensation everyone talks about. After breakfast, my throat felt almost normal.<br>Checked my temperature: just over 37°C. It was dropping. Appetite: still normal.</p><h2 id="December-13-Tuesday-—-Fever-dropping"><a href="#December-13-Tuesday-—-Fever-dropping" class="headerlink" title="December 13, Tuesday — Fever dropping"></a>December 13, Tuesday — Fever dropping</h2><p>Appetite decreased. Limbs felt a bit weak. Lost some sense of taste and smell.</p><p>The kids started showing symptoms. Their fevers began.</p><h2 id="December-14-Wednesday-—-Temperature-normal"><a href="#December-14-Wednesday-—-Temperature-normal" class="headerlink" title="December 14, Wednesday — Temperature normal"></a>December 14, Wednesday — Temperature normal</h2><p>Temperature back to normal. Started coughing up phlegm. Head felt foggy. No taste or smell.</p><h2 id="December-15-Thursday-—-Normal"><a href="#December-15-Thursday-—-Normal" class="headerlink" title="December 15, Thursday — Normal"></a>December 15, Thursday — Normal</h2><p>Temperature normal, but rapid test still shows positive (faintly). Doesn’t matter anymore though — everyone else in the family is starting to show symptoms. Time for me to take care of them.</p><p>And yes, the canned peaches and instant noodles I ordered online still never arrived!</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;Beijing gradually relaxed COVID restrictions in early December. I worked from a coffee shop for a few days, and that’s when I caught it. 
      
    
    </summary>
    
    
    
      <category term="covid" scheme="https://bohutang.me/tags/covid/"/>
    
  </entry>
  
  <entry>
    <title>新冠六天记</title>
    <link href="https://bohutang.me/2022/12/15/covid-22/"/>
    <id>https://bohutang.me/2022/12/15/covid-22/</id>
    <published>2022-12-15T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<p>12 月初北京疫情逐步放开，去咖啡馆办公了几天，结果就中招了，今天基本恢复，记录下全过程。<br>一家人比较难避免，控制好感染时机比较重要，做到互相照顾。</p><h2 id="12-月-10-号，周六，开始发烧"><a href="#12-月-10-号，周六，开始发烧" class="headerlink" title="12 月 10 号，周六，开始发烧"></a>12 月 10 号，周六，开始发烧</h2><p>早上起来感觉嗓子有点不舒服，下午身体开始发冷，体温 37 度，于是在房间隔离，开始戴 N95。</p><p>调皮蛋们在房间门口拉上了警戒线，并贴上了”密接者“告示，玩起了cosplay。</p><p>晚饭时开始升到 38 度，不过食欲正常，就是头疼的厉害，好不容易搞到几个抗原，测试显示阴性。</p><p>半夜烧到 39 度，头疼的非常厉害，做了好多奇怪的梦，这个疼痛很像小时候感冒发烧时的感觉，瞬间想到了方便面或者罐头，上网搜了下黄桃罐头都要买不到了（药就更难买了！），赶紧淘了几袋方便面。</p><h2 id="12-月-11-号，周日，发烧"><a href="#12-月-11-号，周日，发烧" class="headerlink" title="12 月 11 号，周日，发烧"></a>12 月 11 号，周日，发烧</h2><p>黄桃罐头和方便面都没到！</p><p>这天最严重，烧的头痛欲裂，早上测试抗原，已经显示强阳性。食欲正常。</p><p>晚上高烧到了巅峰，超过了 39 度，头疼的几乎睡不着，特别想吃水果（如果有黄桃罐头就好了）。</p><h2 id="12-月-12-号，周一，开始退烧"><a href="#12-月-12-号，周一，开始退烧" class="headerlink" title="12 月 12 号，周一，开始退烧"></a>12 月 12 号，周一，开始退烧</h2><p>经过一晚上的高烧折腾，早上起来嗓子有点不舒服，但是没有大家说的那种”刀片过喉“感觉，吃过早饭嗓子几乎没有任何感觉。<br>测试了下体温，37度多，温度开始下降，食欲正常。</p><h2 id="12-月-13-号，周二，开始退烧"><a href="#12-月-13-号，周二，开始退烧" class="headerlink" title="12 月 13 号，周二，开始退烧"></a>12 月 13 号，周二，开始退烧</h2><p>食欲下降，四肢有点无力，味觉和嗅觉下降。</p><p>小孩开始出现症状，发烧开始。</p><h2 id="12-月-14-号，周三，体温正常"><a href="#12-月-14-号，周三，体温正常" class="headerlink" title="12 月 14 号，周三，体温正常"></a>12 月 14 号，周三，体温正常</h2><p>体温基本正常，开始咳痰，头昏昏沉沉，无味觉和嗅觉。</p><h2 id="12月-15-号，周四，正常"><a href="#12月-15-号，周四，正常" class="headerlink" title="12月 15 号，周四，正常"></a>12月 15 号，周四，正常</h2><p>体温正常，但抗原显示阳性（较弱），不过已经无所谓了，因为家里其他人基本都开始出现症状，轮到我做后勤保障了。</p><p>至此，网上买的黄桃罐头和方便面都没到！</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;12 月初北京疫情逐步放开，去咖啡馆办公了几天，结果就中招了，今天基本恢复，记录下全过程。&lt;br&gt;一家人比较难避免，控制好感染时机比较重要，做到互相照顾。&lt;/p&gt;
&lt;h2 id=&quot;12-月-10-号，周六，开始发烧&quot;&gt;&lt;a href=&quot;#12-月-10-号，周六，开始发烧&quot;
      
    
    </summary>
    
    
    
      <category term="covid" scheme="https://bohutang.me/tags/covid/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse (7) Using Xor Filter to Replace Bloom Filter for Faster Queries</title>
    <link href="https://bohutang.me/2022/11/21/databend-xor-filter/"/>
    <id>https://bohutang.me/2022/11/21/databend-xor-filter/</id>
    <published>2022-11-21T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Background"><a href="#Background" class="headerlink" title="Background"></a>Background</h2><p>In big data analytics, many optimizations revolve around one principle: “reduce distance to the data.”</p><p>The role of a Bloom Filter Index is to probe with the index before accessing storage, then decide whether to actually read data blocks from the backend.</p><img src="https://databend-1253727613.cos.ap-singapore.myqcloud.com/blog/xor-filter/bloom-filter.png" align="center" style="zoom:45%;" /><h2 id="The-Problem-with-Bloom-Filters"><a href="#The-Problem-with-Bloom-Filters" class="headerlink" title="The Problem with Bloom Filters"></a>The Problem with Bloom Filters</h2><p>Most databases you’re familiar with use Bloom Filters to handle equality queries, avoiding unnecessary data reads.</p><p>Databend’s first version (<a href="https://github.com/datafuselabs/databend/pull/6639" target="_blank" rel="noopener">databend#6639</a>) also used the classic Bloom Filter algorithm. Testing revealed some issues:<br>The Bloom Filter Index took up too much space. The index size even exceeded the raw data size (to keep things simple for users, Databend automatically creates Bloom indexes for certain data types). This meant that probing with Bloom wasn’t much different from directly reading backend data, so there wasn’t much performance gain.</p><p>The reason is that Bloom Filters don’t know the cardinality when they’re generated. For example, with a Boolean type, it allocates space based on quantity without considering cardinality (which is 2: True or False).</p><p>So the Databend community started exploring new solutions. The initial viable approach was detecting uniqueness with HyperLogLog, then allocating space accordingly.</p><p>At a TiDB user conference one Saturday in September, Databend had a booth. I met with xp (@drmingdrmer) in person (the Databend team works remotely, so meeting offline isn’t easy 😭). We discussed this problem again. He wanted to solve it using Trie concepts. The idea was good, but the complexity was high.</p><p>xp is an expert in Trie, and implementation wouldn’t be a problem for him. But I had a vague feeling that some existing technology could solve this problem well.</p><img src="https://databend-1253727613.cos.ap-singapore.myqcloud.com/blog/xor-filter/tidb-databend.png" align="center" style="zoom:60%;" /><h2 id="The-Cost-Effective-Xor-Filter"><a href="#The-Cost-Effective-Xor-Filter" class="headerlink" title="The Cost-Effective Xor Filter"></a>The Cost-Effective Xor Filter</h2><p>On Sunday, I did some exploration and discovered the Xor Filter algorithm proposed by Daniel Lemire’s team in 2019: <a href="https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom Filters</a>. Based on the introduction, the results looked very promising.</p><img src="https://lemire.me/blog/wp-content/uploads/2019/12/comparison.png" style="zoom:45%;" /><p>Just to try it out, I ran a test based on the Rust version (<a href="https://github.com/prataprc/xorfilter" target="_blank" rel="noopener">xorfilter</a>) (<a href="https://github.com/BohuTANG/databend/commit/b45793c044c17cc6f8706c42bbe21201590f359f" target="_blank" rel="noopener">Xor Filter Bench</a>). The results were excellent:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">u64:</span><br><span class="line">xor bitmap encode:1230069 bytes, raw:8000000 bytes, ratio:0.15375863</span><br><span class="line"></span><br><span class="line">bool:</span><br><span class="line">xor bitmap encode:61 bytes, raw:1000000 bytes, ratio:0.000061</span><br><span class="line"></span><br><span class="line">string:</span><br><span class="line">xor bitmap encode:123067 bytes, raw:3000000 bytes, ratio:0.041022334</span><br><span class="line"></span><br><span class="line">100000 records of the same key:</span><br><span class="line">xor bitmap encode: 61 bytes, raw:3000000 bytes, ratio:0.000020333333</span><br></pre></td></tr></table></figure><p>So in <a href="https://github.com/datafuselabs/databend/pull/7860" target="_blank" rel="noopener">databend#7860</a>, I implemented the switch from Bloom Filter to Xor Filter. Let’s run some tests to see the results.</p><h3 id="Test-Environment"><a href="#Test-Environment" class="headerlink" title="Test Environment"></a>Test Environment</h3><p>Databend: <a href="https://github.com/datafuselabs/databend/releases/tag/v0.8.122-nightly" target="_blank" rel="noopener">v0.8.122-nightly</a>, single node<br>VM: 32 vCPU, 32 GiB (Cloud VM)<br>Object Store: S3<br>Dataset: 10 billion records, 350GB raw data, 700MB Xor Filter Index, both index and data persisted to object storage<br>Table schema:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; desc t10b;</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br><span class="line">| Field | Type            | Null | Default | Extra |</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br><span class="line">| c1    | BIGINT UNSIGNED | NO   | 0       |       |</span><br><span class="line">| c2    | VARCHAR         | NO   |         |       |</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br></pre></td></tr></table></figure><h3 id="Deploying-Databend"><a href="#Deploying-Databend" class="headerlink" title="Deploying Databend"></a>Deploying Databend</h3><p><strong>Step 1: Download the <a href="https://databend.rs/download" target="_blank" rel="noopener">installer</a></strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget https:&#x2F;&#x2F;github.com&#x2F;datafuselabs&#x2F;databend&#x2F;releases&#x2F;download&#x2F;v0.8.122-nightly&#x2F;databend-v0.8.122-nightly-x86_64-unknown-linux-musl.tar.gz .</span><br><span class="line">tar zxvf databend-v0.8.122-nightly-x86_64-unknown-linux-musl.tar.gz</span><br></pre></td></tr></table></figure><p>After extraction, the directory structure:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">tree</span><br><span class="line">.</span><br><span class="line">├── bin</span><br><span class="line">│   ├── databend-meta</span><br><span class="line">│   ├── databend-metabench</span><br><span class="line">│   ├── databend-metactl</span><br><span class="line">│   └── databend-query</span><br><span class="line">├── configs</span><br><span class="line">│   ├── databend-meta.toml</span><br><span class="line">│   └── databend-query.toml</span><br><span class="line">├── readme.txt</span><br><span class="line">└── scripts</span><br><span class="line">    ├── start.sh</span><br><span class="line">    └── stop.sh</span><br></pre></td></tr></table></figure><p><strong>Step 2: Start Databend Meta</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;bin&#x2F;databend-meta -c configs&#x2F;databend-meta.toml</span><br></pre></td></tr></table></figure><p><strong>Step 3: Configure Databend Query</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim configs&#x2F;databend-query.toml</span><br></pre></td></tr></table></figure><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">... ...</span><br><span class="line"></span><br><span class="line">[meta]</span><br><span class="line">endpoints &#x3D; [&quot;127.0.0.1:9191&quot;]</span><br><span class="line">username &#x3D; &quot;root&quot;</span><br><span class="line">password &#x3D; &quot;root&quot;</span><br><span class="line">client_timeout_in_second &#x3D; 60</span><br><span class="line">auto_sync_interval &#x3D; 60</span><br><span class="line"></span><br><span class="line"># Storage config.</span><br><span class="line">[storage]</span><br><span class="line"># fs | s3 | azblob | obs</span><br><span class="line">type &#x3D; &quot;s3&quot;</span><br><span class="line"></span><br><span class="line"># To use S3-compatible object storage, uncomment this block and set your values.</span><br><span class="line"> [storage.s3]</span><br><span class="line">bucket &#x3D; &quot;&lt;your-bucket-name&gt;&quot;</span><br><span class="line">endpoint_url &#x3D; &quot;&lt;your-s3-endpoint&gt;&quot;</span><br><span class="line">access_key_id &#x3D; &quot;&lt;your-key&gt;&quot;</span><br><span class="line">secret_access_key &#x3D; &quot;&lt;your-access-key&gt;&quot;</span><br></pre></td></tr></table></figure><p>For detailed deployment docs, see: <a href="https://databend.rs/doc/deploy/deploying-databend" target="_blank" rel="noopener">https://databend.rs/doc/deploy/deploying-databend</a></p><p><strong>Step 4: Start Databend Query</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;bin&#x2F;databend-query -c configs&#x2F;databend-query.toml</span><br></pre></td></tr></table></figure><p><strong>Step 5: Build the Test Dataset</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -h127.0.0.1 -P3307</span><br></pre></td></tr></table></figure><p>Generate 10 billion test records (took 16 min 0.41 sec):</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create table t10b as select number as c1, cast(rand() as string) as c2 from numbers(10000000000)</span><br></pre></td></tr></table></figure><p>Query (no caching, data and index entirely in object storage):</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; select * from t10b where  c2&#x3D;&#39;0.6622377673133426&#39;;</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">| c1        | c2                 |</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">| 937500090 | 0.6622377673133426 |</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">1 row in set (20.57 sec)</span><br><span class="line">Read 40000000 rows, 1009.75 MiB in 20.567 sec., 1.94 million rows&#x2F;sec., 49.10 MiB&#x2F;sec.</span><br></pre></td></tr></table></figure><p>A single-node Databend, using filter pushdown and Xor Filter indexing, can perform point queries on 10 billion randomly generated records in about 20 seconds.<br>You can also leverage Databend’s distributed capabilities to speed up point queries. Databend’s design philosophy is elastic compute scaling on a single copy of data. Expanding from a single node to a cluster is very simple: <a href="https://databend.rs/doc/deploy/expanding-to-a-databend-cluster#deploying-a-new-query-node" target="_blank" rel="noopener">Expanding a Standalone Databend</a>.</p><h2 id="References"><a href="#References" class="headerlink" title="References"></a>References</h2><p>[1] Arxiv: <a href="https://arxiv.org/abs/1912.08258" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters</a><br>[2] Daniel Lemire’s blog: <a href="https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom Filters</a><br>[3] Databend, Cloud Lakehouse: <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;Background&quot;&gt;&lt;a href=&quot;#Background&quot; class=&quot;headerlink&quot; title=&quot;Background&quot;&gt;&lt;/a&gt;Background&lt;/h2&gt;&lt;p&gt;In big data analytics, many optimizati
      
    
    </summary>
    
    
    
      <category term="Databend" scheme="https://bohutang.me/tags/Databend/"/>
    
      <category term="xor filter" scheme="https://bohutang.me/tags/xor-filter/"/>
    
      <category term="bloom filter" scheme="https://bohutang.me/tags/bloom-filter/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse（7) 使用 Xor Filter 替换 Bloom Filter 加速查询</title>
    <link href="https://bohutang.me/2022/11/21/databend-xor-filter/"/>
    <id>https://bohutang.me/2022/11/21/databend-xor-filter/</id>
    <published>2022-11-21T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><p>在大数据分析领域，很多优化都是围绕一句话来做：”reduce distance to the data.“</p><p>Bloom Filter Index 的作用是访问 Storage 之前使用布隆索引做下探测，然后决定是否需要从后端读取真正的数据块。</p><img src="https://databend-1253727613.cos.ap-singapore.myqcloud.com/blog/xor-filter/bloom-filter.png" align="center" style="zoom:45%;" /><h2 id="有问题的-Bloom-Filter"><a href="#有问题的-Bloom-Filter" class="headerlink" title="有问题的 Bloom Filter"></a>有问题的 Bloom Filter</h2><p>大家所熟悉的数据库，大部分都在使用 Bloom Filter 解决等值查询的问题，避免做一些无用的数据读取。</p><p>Databend 第一版( <a href="https://github.com/datafuselabs/databend/pull/6639" target="_blank" rel="noopener">databend#6639</a>) 使用的也是 Bloom Filter 经典算法，经过测试发现了一些问题：<br>Bloom Filter Index 的索引空间占用过大，Bloom Filter Index 大小甚至超过了原始数据大小（为了让用户简单易用，Databend 会自动为某些数据类型创建 Bloom 索引），这样做 Bloom 检测跟直接读取后端数据区别不大，所以并没有太大的性能提升。</p><p>原因是 Bloom Filter 生成时并不知道数据的基数，比如 Boolean 类型，它也会根据数目分配空间，并不会关注基数问题（基数为 2，True or False）。</p><p>于是 Databend  社区开始了新方案的探索之路，初步确定一个可行方案是通过 HyperLoglog 检测出数据唯一度，然后做空间分配。</p><p>9 月份某个周六的 TiDB 用户大会上，Databend 有个展台，跟 xp(@drmingdrmer) 见面（Databend 团队是 Remote 办公，大家线下见面不太容易 😭）重新讨论起这个问题，他想用 Trie 思想来解决，思路挺好，但复杂度较高。</p><p>xp 是 Trie 领域的高手，工程实现来对他来说不是问题，但隐约感觉一些现有技术可以很好的解决这个问题。</p><img src="https://databend-1253727613.cos.ap-singapore.myqcloud.com/blog/xor-filter/tidb-databend.png" align="center" style="zoom:60%;" /><h2 id="高性价比的-Xor-Filter"><a href="#高性价比的-Xor-Filter" class="headerlink" title="高性价比的 Xor Filter"></a>高性价比的 Xor Filter</h2><p>周日进行了一番探索，发现了 Daniel Lemire 团队在 2019 年提出的 Xor Filter 算法: <a href="https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom Filters</a>，从介绍看效果非常不错。</p><img src="https://lemire.me/blog/wp-content/uploads/2019/12/comparison.png" style="zoom:45%;" /><p>抱着试试看的心理，基于 Rust 版（<a href="https://github.com/prataprc/xorfilter" target="_blank" rel="noopener">xorfilter</a>）做了一个测试 （<a href="https://github.com/BohuTANG/databend/commit/b45793c044c17cc6f8706c42bbe21201590f359f" target="_blank" rel="noopener">Xor Filter Bench</a>，发现疗效非常不错：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">u64: </span><br><span class="line">xor bitmap encode:1230069 bytes, raw:8000000 bytes, ratio:0.15375863</span><br><span class="line"></span><br><span class="line">bool:</span><br><span class="line">xor bitmap encode:61 bytes, raw:1000000 bytes, ratio:0.000061</span><br><span class="line"></span><br><span class="line">string:</span><br><span class="line">xor bitmap encode:123067 bytes, raw:3000000 bytes, ratio:0.041022334</span><br><span class="line"></span><br><span class="line">100000 records of the same key:</span><br><span class="line">xor bitmap encode: 61 bytes, raw:3000000 bytes, ratio:0.000020333333</span><br></pre></td></tr></table></figure><p>于是，在 <a href="https://github.com/datafuselabs/databend/pull/7860" target="_blank" rel="noopener">databend#7860</a> 实现了 Bloom Filter 到 Xor Filter 的切换，让我们做一些测试来看看效果。</p><h3 id="测试环境"><a href="#测试环境" class="headerlink" title="测试环境"></a>测试环境</h3><p>Databend: <a href="https://github.com/datafuselabs/databend/releases/tag/v0.8.122-nightly" target="_blank" rel="noopener">v0.8.122-nightly</a>，单节点<br>VM: 32 vCPU, 32 GiB (Cloud VM)<br>Object Store: S3<br>数据集: 100 亿记录，350G Raw Data，Xor Filter Index 700MB，索引和数据全部持久化到对象存储<br>表结构:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; desc t10b;</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br><span class="line">| Field | Type            | Null | Default | Extra |</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br><span class="line">| c1    | BIGINT UNSIGNED | NO   | 0       |       |</span><br><span class="line">| c2    | VARCHAR         | NO   |         |       |</span><br><span class="line">+-------+-----------------+------+---------+-------+</span><br></pre></td></tr></table></figure><h3 id="部署-Databend"><a href="#部署-Databend" class="headerlink" title="部署 Databend"></a>部署 Databend</h3><p><strong>Step1：下载<a href="https://databend.rs/download" target="_blank" rel="noopener">安装包</a></strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget https:&#x2F;&#x2F;github.com&#x2F;datafuselabs&#x2F;databend&#x2F;releases&#x2F;download&#x2F;v0.8.122-nightly&#x2F;databend-v0.8.122-nightly-x86_64-unknown-linux-musl.tar.gz .</span><br><span class="line">tar zxvf databend-v0.8.122-nightly-x86_64-unknown-linux-musl.tar.gz</span><br></pre></td></tr></table></figure><p>解压后目录结构：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">tree</span><br><span class="line">.</span><br><span class="line">├── bin</span><br><span class="line">│   ├── databend-meta</span><br><span class="line">│   ├── databend-metabench</span><br><span class="line">│   ├── databend-metactl</span><br><span class="line">│   └── databend-query</span><br><span class="line">├── configs</span><br><span class="line">│   ├── databend-meta.toml</span><br><span class="line">│   └── databend-query.toml</span><br><span class="line">├── readme.txt</span><br><span class="line">└── scripts</span><br><span class="line">    ├── start.sh</span><br><span class="line">    └── stop.sh</span><br></pre></td></tr></table></figure><p><strong>Step2：启动 Databend Meta</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;bin&#x2F;databend-meta -c configs&#x2F;databend-meta.toml</span><br></pre></td></tr></table></figure><p><strong>Step3：配置 Databend Query</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim configs&#x2F;databend-query.toml</span><br></pre></td></tr></table></figure><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">... ...</span><br><span class="line"></span><br><span class="line">[meta]</span><br><span class="line">endpoints &#x3D; [&quot;127.0.0.1:9191&quot;]</span><br><span class="line">username &#x3D; &quot;root&quot;</span><br><span class="line">password &#x3D; &quot;root&quot;</span><br><span class="line">client_timeout_in_second &#x3D; 60</span><br><span class="line">auto_sync_interval &#x3D; 60</span><br><span class="line"></span><br><span class="line"># Storage config.</span><br><span class="line">[storage]</span><br><span class="line"># fs | s3 | azblob | obs</span><br><span class="line">type &#x3D; &quot;s3&quot;</span><br><span class="line"></span><br><span class="line"># To use S3-compatible object storage, uncomment this block and set your values.</span><br><span class="line"> [storage.s3]</span><br><span class="line">bucket &#x3D; &quot;&lt;your-bucket-name&gt;&quot;</span><br><span class="line">endpoint_url &#x3D; &quot;&lt;your-s3-endpoint&gt;&quot;</span><br><span class="line">access_key_id &#x3D; &quot;&lt;your-key&gt;&quot;</span><br><span class="line">secret_access_key &#x3D; &quot;&lt;your-access-key&gt;&quot;</span><br></pre></td></tr></table></figure><p>详细部署文档请参考： <a href="https://databend.rs/doc/deploy/deploying-databend" target="_blank" rel="noopener">https://databend.rs/doc/deploy/deploying-databend</a></p><p><strong>Step4： 启动 Databend Query</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;bin&#x2F;databend-query -c configs&#x2F;databend-query.toml</span><br></pre></td></tr></table></figure><p><strong>Step5： 构造测试数据集</strong></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -h127.0.0.1 -P3307</span><br></pre></td></tr></table></figure><p>构造 100 亿条测试数据(耗时 16 min 0.41 sec):</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">create table t10b as select number as c1, cast(rand() as string) as c2 from numbers(10000000000)</span><br></pre></td></tr></table></figure><p>查询（无任何缓存，数据和索引全部在对象存储）：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; select * from t10b where  c2&#x3D;&#39;0.6622377673133426&#39;;</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">| c1        | c2                 |</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">| 937500090 | 0.6622377673133426 |</span><br><span class="line">+-----------+--------------------+</span><br><span class="line">1 row in set (20.57 sec)</span><br><span class="line">Read 40000000 rows, 1009.75 MiB in 20.567 sec., 1.94 million rows&#x2F;sec., 49.10 MiB&#x2F;sec.</span><br></pre></td></tr></table></figure><p>单节点 Databend 利用 filter 下推，然后使用 Xor Filter 索引做过滤，在 100 亿规模的随机数据上做点式查询，可以在 20s 左右。<br>也可以利用 Databend 的分布式能力来加速点查，Databend 的设计理念是一份数据计算弹性扩展，从单节点扩展到集群模式也非常简单：<a href="https://databend.rs/doc/deploy/expanding-to-a-databend-cluster#deploying-a-new-query-node" target="_blank" rel="noopener">Expanding a Standalone Databend</a>。</p><h2 id="References"><a href="#References" class="headerlink" title="References"></a>References</h2><p>[1] Arxiv: <a href="https://arxiv.org/abs/1912.08258" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters</a><br>[2] Daniel Lemire’s blog: <a href="https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/" target="_blank" rel="noopener">Xor Filters: Faster and Smaller Than Bloom Filters</a><br>[3] Databend, Cloud Lakehouse: <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;背景&quot;&gt;&lt;a href=&quot;#背景&quot; class=&quot;headerlink&quot; title=&quot;背景&quot;&gt;&lt;/a&gt;背景&lt;/h2&gt;&lt;p&gt;在大数据分析领域，很多优化都是围绕一句话来做：”reduce distance to the data.“&lt;/p&gt;
&lt;p&gt;Bloom Fil
      
    
    </summary>
    
    
    
      <category term="Databend" scheme="https://bohutang.me/tags/Databend/"/>
    
      <category term="xor filter" scheme="https://bohutang.me/tags/xor-filter/"/>
    
      <category term="bloom filter" scheme="https://bohutang.me/tags/bloom-filter/"/>
    
  </entry>
  
  <entry>
    <title>My Story with TokuDB</title>
    <link href="https://bohutang.me/2022/05/20/tokudb/"/>
    <id>https://bohutang.me/2022/05/20/tokudb/</id>
    <published>2022-05-20T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<p>I spend a lot of time on Zhihu pretending to be an expert, giving advice to beginners about learning database technology. Today, let me tell you how I actually got into the database world — my story with TokuDB.</p><p>What is TokuDB anyway?</p><p>TokuDB is an “antique.” It was wildly popular back in the HDD era. It had great compression and solid read/write performance, which made it useful for solving capacity and performance problems at scale.</p><p>This story really starts with LevelDB.</p><p>In 2011, LevelDB went open source. I was immediately drawn to this clean key-value store. I quickly dove into the source code and understood its internal mechanics. That project officially kicked off my database journey.</p><p>While building prototypes, I kept up with the latest database developments. I followed almost every database-related tag on Twitter. Every morning, the first thing I’d do was read through those tweets. Database technology felt so fascinating and prestigious. I was constantly thinking about how to get good at it quickly!</p><p>Things got interesting in 2012. I started implementing Skip Lists, then figuring out how to optimize them. Once I got bored with Skip Lists, I moved on to B-Trees. Eventually, I could write a B-Tree while waiting for a table at a restaurant. I thought: “Is that all there is to databases?” So I decided to implement a complete key-value store. Project codename: <a href="https://github.com/BohuTANG/nessDB" target="_blank" rel="noopener">nessDB</a>.</p><p>While working on nessDB, I stumbled upon the “Cache-Oblivious B-Trees” series from MIT CSAIL. They made a constant-factor optimization to B-Trees that dramatically reduced overall I/O. Based on this idea, they founded TokuTek and went all-in on developing TokuDB. The team was mostly the professors’ star students: 3 graduate students on development, plus Rik, a veteran from Bell Labs, as architect (this guy is incredible — a true embodiment of the hardcore Bell Labs spirit. He’s retired now. I tried to recruit him to our startup a while back, but family commitments prevented him from working full-time).</p><p>TokuDB was closed source at the time. Most of the information came from the TokuTek website and a few papers from the professors. In late 2012, I finally got in touch with Leif, the lead developer on TokuDB. We’d chat every week via GTalk. With Leif’s expert guidance, I implemented a simplified version of TokuDB (<a href="https://bohutang.me/2020/06/20/clickhouse-and-friends-merge-tree-algo/">Fractal-Tree Index</a>) in 2013. I felt like I’d reached the peak of my career. My whole walk changed. I’d become someone who mastered core database technology!</p><p>On April 22, 2013, TokuDB went open source. I started studying the source code and found it mostly matched my expectations. But to integrate TokuDB into MySQL as a storage engine, they’d done a ton of work. For example, tokudb-engine was the layer that interfaced with MySQL’s plugin system, while the real core was ft-index — a key-value store built on Fractal-Tree.</p><p>Soon after, my work required me to dive deep into TokuDB development. First, I implemented hot backup for TokuDB so Xtrabackup could also hot-backup TokuDB data. This required some kernel-level changes to TokuDB. I shared my approach with TokuTek, and their VP Tim sent me an email:<br><code>Hey, send me your name/address, we owe you something as the &quot;first TokuDB contributor&quot;!</code></p><p>They sent me a TokuMX t-shirt from the US (TokuMX was MongoDB based on TokuDB — back when MongoDB was still struggling with MMAP, TokuMX had quite a few users), along with a small blue TokuDB sticker that simply said “First TokuDB Contributor.”</p><p>I was thrilled. I still remember that sunny afternoon at the bustling WFC, receiving a beat-up woven bag carried by FedEx. This was care from across the ocean!</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/posts/tokutek.jpg" style="zoom:60%;"/><p>For a while after that, TokuTek kept working on open-source TokuDB, but there was barely a community. It was hard for outsiders to contribute. Plus, they were extremely capable — they could refactor a major module in just a few weeks. I maintained our company’s internal TokuDB fork in isolation, fixing bugs and adding features.</p><p>In April 2015, I enthusiastically invited Leif to China. I took him to some famous tourist spots. The day before he left, Leif found a bar in Houhai. He said boldly that since he’d be back in the US and couldn’t use the RMB anyway, we should drink until we dropped.</p><p>Leif ordered drinks while describing their flavors and popularity in the US. With each new drink, he’d taste it first, then rotate the glass 180 degrees for me to try. After a while, Leif revealed some news: TokuDB had been sold to Percona, and none of the original team would be joining them. The reason was… well, lots of reasons. Google had made an offer to the team, but Leif swore he’d never touch the database industry again. He said it was <strong>too brutal</strong>. Clearly, the TokuDB experience had left some scars.</p><p>After Percona acquired TokuDB, it quickly became a mess and slowly fell into disrepair. Their CTO invited me to join several times, but I politely declined.</p><p>In 2016, Rik and I founded the <a href="https://github.com/xelabs" target="_blank" rel="noopener">XeLabs</a> organization to maintain the TokuDB fork. This version was used by several companies and stably supported tens of thousands of TokuDB instances. Eventually, due to limited bandwidth, the project went dormant. Maintaining a MySQL fork isn’t easy — even a small change requires tons of testing. Fortunately, TokuDB’s engineering quality was excellent, so bugs were rare. Even now, it’s pretty stable. But these days, it’s all about cloud databases. Few people deploy MySQL themselves anymore.</p><p>That’s my story with TokuDB.</p><p>I also have stories with distributed databases, and with data warehouses. So many stories, it’s almost overwhelming.</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;I spend a lot of time on Zhihu pretending to be an expert, giving advice to beginners about learning database technology. Today, let me t
      
    
    </summary>
    
    
    
      <category term="tokudb" scheme="https://bohutang.me/tags/tokudb/"/>
    
  </entry>
  
  <entry>
    <title>虎哥与TokuDB的故事</title>
    <link href="https://bohutang.me/2022/05/20/tokudb/"/>
    <id>https://bohutang.me/2022/05/20/tokudb/</id>
    <published>2022-05-20T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<p>天天在知乎上装大佬给新手们指点迷津，告诉大家学习数据库技术的方法，今天就来聊聊虎哥是怎么进入数据库圈的，和 TokuDB 的故事。</p><p>TokuDB 又是个什么东东呢？</p><p>TokuDB 是一个“老古董“，在机械硬盘时代曾风靡一时，它有着不错的压缩，同时又兼具着不错的读、写能力，被各大厂用来解决容量+性能问题。</p><p>这个故事还得从 LevelDB 说起。</p><p>2011年，LevelDB 开放源代码，当时虎哥被这个清新的 kv 给吸引住了，很快就把它的源码翻了个底朝天，大概熟悉了这个 kv 的内部运行机制，从这个项目开始虎哥就正式开启了他的数据库之旅。</p><p>一边着手写原型，一边跟踪数据库技术的最新进展，当时虎哥把推上一些跟数据库相关的 tag 几乎都关注了，每天早上第一件事就是翻阅这些 tag 相关的推文，数据库这种高大上的技术太有吸引力了，每天都在琢磨着怎么能快速入门！</p><p>有趣的的事情是从 2012 年开始的，虎哥开始尝试实现 Skip List，然后琢磨怎么优化它，Skip List 玩腻了就开始玩 B-Tree，最后无聊到在饭馆门口等座的时候就可以写一个 B-Tree，当时想：数据库就这？于是决定再实现一个完整版的 kv ，项目代号 <a href="https://github.com/BohuTANG/nessDB" target="_blank" rel="noopener">nessDB</a>。</p><p>在研发 nessDB 过程中，偶然发现了来自 MIT CSAIL 的《Cache-Oblivious B-Trees》系列，他们通过对 B-Tree 做一个常数项优化从而让整体 IO 大幅降低，基于这个想法他们创立了 TokuTek 这家公司，全力研发 TokuDB 产品，干活的基本都是老板们最得意的学生，3 个学生做研发，外加贝尔实验室的老手 Rik 做架构（这位老哥是个神人，能力非常了得，贝尔实验室硬核精神的体现者，目前已经退休，前段时间还邀请他加入我们的初创公司，由于家庭原因，暂时无法全职工作）。</p><p>当时 TokuDB 还是闭源产品，很多资料都是来自 TokuTek 官网以及老板们的几篇 Paper，2012 年底终于跟 TokuDB 主程 Leif 取得了联系，每周我们都会通过gtalk 进行沟通，在 Leif 专业的指导下，虎哥在 2013 年实现一个非常简化的 TokuDB(<a href="https://bohutang.me/2020/06/20/clickhouse-and-friends-merge-tree-algo/">Fractal-Tree Index</a>)，感觉到达了人生的巅峰，走路姿势都不一样了，成为了掌握数据库核心技术的人！</p><p>2013 年 4月 22 号，TokuDB 正式开源，虎哥开始研究其源码，最后发现跟之前推测的差不太多，但是 TokuDB 为了集成到 MySQL 作为一个 Storage Engine，做了大量的工作，比如 tokudb-engine 就是对接 MySQL Plugin 层的，而真正核心的是 ft-index，一个基于 Fractal-Tree 实现的 kv 存储。</p><p>随后，虎哥由于工作需要就全面投入 TokuDB 的研发工作，先是给 TokuDB 实现了一个 hot backup，让 Xtrabackup 也可以热备 TokuDB 的数据，这个过程需要对 TokuDB 内核做一些改动，虎哥把这个思路同步给了 TokuTek，结果他们当时的VP Tim 给发了一份邮件：<br><code>Hey, send me your name/address, we owe you something as the &quot;first TokuDB contributor&quot;!</code></p><p>结果他们从美国给邮寄了一个 TokuMX 的T恤，TokuMX 是基于 TokuDB 的 MongoDB（当时的 MongoDB 还在使用 MMAP 苦苦挣扎，TokuMX 当时有不少用户），还有一个小小的 TokuDB 蓝色贴纸，上面简单的印着 “First TokuDB Contributor”。</p><p>虎哥内心是无比激动的，依然记得那个阳光明媚的下午，在繁华的 WFC 收到了一个被磨蜕皮的编织袋，由FedEx承运，这是来自大洋彼岸的关怀！</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/posts/tokutek.jpg" style="zoom:60%;"/><p>随后的一段时间内，开源 TokuDB 都是 TokuTek 在折腾，几乎没有社区可言，这种东西外人很难入手，而且他们的能力极强，重构一个大的模块几周就搞定，虎哥也孤独的维护着公司内部的 TokuDB 分支，修 bug，增加 feature。</p><p>2015 年 4 月份，虎哥盛情邀请 Leif 来中国，带他逛了一些知名景点，临走前一天，Leif 找了后海的一家酒吧，很豪情的说反正回到美国，换汇的人民币也用不着了，咱们不醉不归。</p><p>Leif 边点酒边介绍这个酒的味道以及在美国的欢迎度，每点一个新酒，自己先尝一口后再把口杯转 180 度，俩人整了半天，最后 Leif 透漏一个消息，TokuDB 已经被老板卖给了Percona，他们原班人马一个都不会过去，理由是 bla bla…，Google 给了他们团队发了 Offer，但他发誓这辈子再也不碰 Database 这个行业，说是<strong>太辛苦</strong>，看来 TokuDB 这个事情对他们伤害蛮大。</p><p>话说 TokuDB 被 Percona 收购后，很快成为了一个烂摊子，也慢慢停止维护，他们 CTO 也多次邀请虎哥加入，都被婉拒。</p><p>2016 年，虎哥和 Rik 成立了 <a href="https://github.com/xelabs" target="_blank" rel="noopener">XeLabs</a> 组织，负责 TokuDB 版本的持续维护，这个版本被多家公司使用，稳定支撑着上万个 TokuDB 实例运行，最终由于精力有限，项目也逐渐停更，维护 MySQL 版本没那么容易，改一个小地方就需要做一堆测试，好歹 TokuDB 工程质量非常好，bug 已经很少，即使现在使用问题也不大，只是现在是 Cloud Database 的天下，很少有人再去部署 MySQL 了。</p><p>好了，这就是虎哥和 TokuDB 的故事。</p><p>虎哥还有和分布式数据库的故事，和数仓的故事，故事太多了，真惆怅。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;天天在知乎上装大佬给新手们指点迷津，告诉大家学习数据库技术的方法，今天就来聊聊虎哥是怎么进入数据库圈的，和 TokuDB 的故事。&lt;/p&gt;
&lt;p&gt;TokuDB 又是个什么东东呢？&lt;/p&gt;
&lt;p&gt;TokuDB 是一个“老古董“，在机械硬盘时代曾风靡一时，它有着不错的压缩，同时
      
    
    </summary>
    
    
    
      <category term="tokudb" scheme="https://bohutang.me/tags/tokudb/"/>
    
  </entry>
  
  <entry>
    <title>Using ECDSA to Replace RSA for SSH Key Generation</title>
    <link href="https://bohutang.me/2022/05/08/ecdsa-rsa/"/>
    <id>https://bohutang.me/2022/05/08/ecdsa-rsa/</id>
    <published>2022-05-08T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<h2 id="RSA"><a href="#RSA" class="headerlink" title="RSA"></a>RSA</h2><p>Many people still use the RSA algorithm to generate SSH public keys. You might even wonder how many bits are safe enough. The general recommendation is 4096 bits:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -b 4096 -C &quot;your_email@example.com&quot;</span><br></pre></td></tr></table></figure><p>This results in a very long public key:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cat test_rsa_4096.pub</span><br><span class="line"></span><br><span class="line">ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCXlH8OxqMFhv2+En10yV2ZorDzRFXQm9pPuWQ8G5iu+cUpyhwDoKnd+l6PCZTrCgcVJgLSsVAVbZ3CK6Qnoj3TDQl4yaj90UasmivWM2INc2hObr5P2y2AqWnnZBXmxpoUGZPz&#x2F;9323JalC+m&#x2F;EwXNcdrC5JzgD083BC0ykfB801vcAzrZwsnbKfCUsGfUNP9mco3+hFwTqgfJxEvmI3X6hbGIGY1d2QbGMLrs3JYVsfRzJDjFaYOSwXZR6pM5uUCKENt9hOmVUZfuZqvlzLZX95yc53a6qNgOJhzaFZYz3wD2gY0dNp1boGnAtXsLqEnqtm9skp05iMuT01B9WrKEOZG5rsRZDh3bYXJ8ZP0lO&#x2F;RbStuBczd8ZgObb32NfUyHG2JObDpm9mjsvWZqJxJbT5l&#x2F;6vMXu8hQ6ikDrf6R33PRcRdbUIrAOpDUrfBxjkUonxjqqEbHhpcAlMWNJ4qcjtjvSnLOhH9GBn5KCnFJ7VIbyXc+Gj9AAp9xuV&#x2F;9jv1R7CathkS2QrC5s9pFY3I24mFevpkioEeJYPAYUTuFBenWg5MdFK99FYO44wjmFa&#x2F;RxwEQtYFXV+RybTJTC0eDpjK1u3w7LVm2JjEVoSfOJIKt9yZQn5Fm0kmueBz5aQ4CzZNoZBMKr7TT0dX9cJoANzd19uM4uCV6HRVJmQyz4Q&#x3D;&#x3D; your_email@example.com</span><br></pre></td></tr></table></figure><h2 id="Ed25519"><a href="#Ed25519" class="headerlink" title="Ed25519"></a>Ed25519</h2><p>There are actually more advanced algorithms that are more secure than RSA, with shorter public keys. Thanks to blockchain adoption, they’re gaining more acceptance. For example, Ed25519, despite being only 256 bits, offers higher security than RSA 3072.</p><p>Generating an Ed25519 SSH Key:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot;</span><br></pre></td></tr></table></figure><p>Public key:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cat test_ed25519.pub</span><br><span class="line">ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGcMXqCXtcjny9gXV1NDmwArHy0AgJs+R7N6XpOutviw your_email@example.com</span><br></pre></td></tr></table></figure><p>GitHub now recommends Ed25519 by default: <a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent" target="_blank" rel="noopener">https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent</a></p><p>Ed25519 is an elliptic curve — elegant and with mathematically proven security:</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/posts/ed25519.png" style="zoom:45%;">         By Deirdre Connolly in [State of the Curve] (2016)<p>Here’s a list of current Ed25519 adopters: <a href="https://ianix.com/pub/ed25519-deployment.html" target="_blank" rel="noopener">https://ianix.com/pub/ed25519-deployment.html</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;RSA&quot;&gt;&lt;a href=&quot;#RSA&quot; class=&quot;headerlink&quot; title=&quot;RSA&quot;&gt;&lt;/a&gt;RSA&lt;/h2&gt;&lt;p&gt;Many people still use the RSA algorithm to generate SSH public key
      
    
    </summary>
    
    
    
      <category term="ecdsa" scheme="https://bohutang.me/tags/ecdsa/"/>
    
      <category term="ed25519" scheme="https://bohutang.me/tags/ed25519/"/>
    
      <category term="rsa" scheme="https://bohutang.me/tags/rsa/"/>
    
  </entry>
  
  <entry>
    <title>使用 ECDSA 替换 RSA 生成 SSH Key</title>
    <link href="https://bohutang.me/2022/05/08/ecdsa-rsa/"/>
    <id>https://bohutang.me/2022/05/08/ecdsa-rsa/</id>
    <published>2022-05-08T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<h2 id="RSA"><a href="#RSA" class="headerlink" title="RSA"></a>RSA</h2><p>相信很多同学还在使用 RSA 算法用于生成 SSH 公钥，可能还会纠结选择多少位才足够安全，一般建议是 4096 bits:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -b 4096 -C &quot;your_email@example.com&quot;</span><br></pre></td></tr></table></figure><p>这样我们的公钥(public key) 就会非常长：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cat test_rsa_4096.pub</span><br><span class="line"></span><br><span class="line">ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCXlH8OxqMFhv2+En10yV2ZorDzRFXQm9pPuWQ8G5iu+cUpyhwDoKnd+l6PCZTrCgcVJgLSsVAVbZ3CK6Qnoj3TDQl4yaj90UasmivWM2INc2hObr5P2y2AqWnnZBXmxpoUGZPz&#x2F;9323JalC+m&#x2F;EwXNcdrC5JzgD083BC0ykfB801vcAzrZwsnbKfCUsGfUNP9mco3+hFwTqgfJxEvmI3X6hbGIGY1d2QbGMLrs3JYVsfRzJDjFaYOSwXZR6pM5uUCKENt9hOmVUZfuZqvlzLZX95yc53a6qNgOJhzaFZYz3wD2gY0dNp1boGnAtXsLqEnqtm9skp05iMuT01B9WrKEOZG5rsRZDh3bYXJ8ZP0lO&#x2F;RbStuBczd8ZgObb32NfUyHG2JObDpm9mjsvWZqJxJbT5l&#x2F;6vMXu8hQ6ikDrf6R33PRcRdbUIrAOpDUrfBxjkUonxjqqEbHhpcAlMWNJ4qcjtjvSnLOhH9GBn5KCnFJ7VIbyXc+Gj9AAp9xuV&#x2F;9jv1R7CathkS2QrC5s9pFY3I24mFevpkioEeJYPAYUTuFBenWg5MdFK99FYO44wjmFa&#x2F;RxwEQtYFXV+RybTJTC0eDpjK1u3w7LVm2JjEVoSfOJIKt9yZQn5Fm0kmueBz5aQ4CzZNoZBMKr7TT0dX9cJoANzd19uM4uCV6HRVJmQyz4Q&#x3D;&#x3D; your_email@example.com</span><br></pre></td></tr></table></figure><h2 id="Ed25519"><a href="#Ed25519" class="headerlink" title="Ed25519"></a>Ed25519</h2><p>其实，有一些更先进的算法，比 RSA 更安全，公钥更简短，随着区块链的普及，它们正慢慢被更多的人接受，比如 Ed25519，虽然它只有 256 bit，但安全性比 RSA 3072 还要高。</p><p>Ed25519 SSH Key 生成：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot;</span><br></pre></td></tr></table></figure><p>公钥：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cat test_ed25519.pub </span><br><span class="line">ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGcMXqCXtcjny9gXV1NDmwArHy0AgJs+R7N6XpOutviw your_email@example.com</span><br></pre></td></tr></table></figure><p>Github 已经默认推荐大家使用 Ed25519: <a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent" target="_blank" rel="noopener">https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent</a></p><p>Ed25519 是一个椭圆曲线，非常优美，安全性经过数学严格证明：</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/posts/ed25519.png" style="zoom:45%;">         By Deirdre Connolly in [State of the Curve] (2016)<p>这里有一份目前使用 Ed25519 的列表： <a href="https://ianix.com/pub/ed25519-deployment.html" target="_blank" rel="noopener">https://ianix.com/pub/ed25519-deployment.html</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h2 id=&quot;RSA&quot;&gt;&lt;a href=&quot;#RSA&quot; class=&quot;headerlink&quot; title=&quot;RSA&quot;&gt;&lt;/a&gt;RSA&lt;/h2&gt;&lt;p&gt;相信很多同学还在使用 RSA 算法用于生成 SSH 公钥，可能还会纠结选择多少位才足够安全，一般建议是 4096 bits:&lt;/p&gt;
      
    
    </summary>
    
    
    
      <category term="ecdsa" scheme="https://bohutang.me/tags/ecdsa/"/>
    
      <category term="ed25519" scheme="https://bohutang.me/tags/ed25519/"/>
    
      <category term="rsa" scheme="https://bohutang.me/tags/rsa/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse (4) How Databend Community Does Testing</title>
    <link href="https://bohutang.me/2021/09/14/databend-cloud-warehouse-how-to-test/"/>
    <id>https://bohutang.me/2021/09/14/databend-cloud-warehouse-how-to-test/</id>
    <published>2021-09-14T15:41:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p>Databend is an open-source, cloud-native data warehouse built in Rust. It aims to provide lightning-fast elastic scaling and deliver an on-demand, pay-as-you-go Data Cloud experience.<br>Open source repo: <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p></blockquote><p>Databend has been open source from day one. The testing system is also built on the open-source ecosystem, heavily using GitHub CI (for free), which has supported our rapid iteration for the past six months.</p><p>For an open-source database project, testability is the key to accelerating iteration. When a Pull Request (commonly called a Patch) goes from submission to merging into the main branch, reviewers typically focus on these questions:</p><ol><li>Does it break functionality?</li><li>Does it affect distributed execution?</li><li>Are there cross-platform compilation issues?</li><li>Does it degrade performance?</li></ol><p>This post walks through a Pull Request’s testing cycle — from creation to merging into the main branch — to see what tests Databend runs. We’ll address the four questions above so every Pull Request has quality assurance.</p><h3 id="Unit-Tests"><a href="#Unit-Tests" class="headerlink" title="Unit Tests"></a><strong>Unit Tests</strong></h3><p>Unit tests are the smallest testing units.</p><p>Every function we write should be independently testable. If the function has state dependencies, those states should be mockable.</p><p>In Databend, unit tests are placed in separate files, like x_test.rs:</p><figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#[test]</span></span><br><span class="line"><span class="function"><span class="keyword">fn</span> <span class="title">test_y</span></span>() -&gt; <span class="built_in">Result</span>&lt;()&gt; &#123;</span><br><span class="line">   ... ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>Currently, Databend has 500+ unit tests. We’ve globally mocked some states to make it easier for developers to write test cases. This ensures functions execute as expected at the code level, catching and fixing problems early.</p><p>Databend’s unit tests run on both Ubuntu and MacOS (the two main systems Databend developers use).</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-unit.png" style="zoom:50%;"/><h3 id="Functional-Tests"><a href="#Functional-Tests" class="headerlink" title="Functional Tests"></a><strong>Functional Tests</strong></h3><p>Passing unit tests doesn’t necessarily guarantee correctness, because functionality usually comes from multiple functions working together logically.</p><p>Functional tests are divided into Stateless and Stateful models. Stateless tests don’t require loading datasets, while Stateful tests need pre-loaded datasets. Let’s focus on the Stateless model.</p><p>Databend follows ClickHouse’s approach, using the <code>numbers_mt</code> table function for convenient Stateless testing.</p><p>For example, this slightly “complex” SQL:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">SELECT number%3 as c1, number%2 as c2 FROM numbers_mt(10000) WHERE number &gt; 2 GROUP BY number%3, number%2 ORDER BY c1, c2;</span><br></pre></td></tr></table></figure><p>It filters data by condition, then performs GROUP BY aggregation, and finally sorts. This SQL execution involves many functions, so we need a convenient mechanism to ensure the combined functionality is correct.</p><p>How does Databend do it?</p><p>We first define a set of SQLs to test, x.sql:</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="built_in">number</span>%<span class="number">3</span> <span class="keyword">as</span> c1, <span class="built_in">number</span>%<span class="number">2</span> <span class="keyword">as</span> c2 <span class="keyword">FROM</span> numbers_mt(<span class="number">10000</span>) <span class="keyword">WHERE</span> <span class="built_in">number</span> &gt; <span class="number">2</span> <span class="keyword">GROUP</span> <span class="keyword">BY</span> <span class="built_in">number</span>%<span class="number">3</span>, <span class="built_in">number</span>%<span class="number">2</span> <span class="keyword">ORDER</span> <span class="keyword">BY</span> c1, c2;</span><br></pre></td></tr></table></figure><p>Then we define the expected result set, x.result:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">0  0</span><br><span class="line">0  1</span><br><span class="line">1  0</span><br><span class="line">1  1</span><br><span class="line">2  0</span><br><span class="line">2  1</span><br></pre></td></tr></table></figure><p>During functional testing, Databend runs the x.sql file, then compares the result set with the x.result file. If there’s a discrepancy, it errors out and provides hints.</p><p>Since Databend has distributed MPP capabilities, functional tests run in both Standalone and Cluster modes for regression testing to ensure patches don’t break functionality.</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-stateless.png" style="zoom:50%;"/><h3 id="Performance-Tests"><a href="#Performance-Tests" class="headerlink" title="Performance Tests"></a><strong>Performance Tests</strong></h3><p>After unit and functional tests pass, we also care about an important metric: does this patch degrade performance? Or if it’s a performance optimization patch, how much does it improve?</p><p>To answer this question, Databend uses quantifiable numbers. We just reply in the Pull Request: <code>/run-perf master</code>. CI automatically compiles the current branch, runs performance tests, compares with master, and generates a performance comparison report:</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-perf-report.png" style="zoom:50%;"/><p>This way, reviewers can clearly see the patch’s performance impact from the report, ensuring every patch’s performance is under control.</p><h3 id="Compilation-Tests"><a href="#Compilation-Tests" class="headerlink" title="Compilation Tests"></a><strong>Compilation Tests</strong></h3><p>Databend aims to build a cross-platform Cloud Warehouse, so every patch must compile and work properly on these platforms:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: x86_64-unknown-linux-gnu, cross: false&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: aarch64-unknown-linux-gnu, cross: true&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: arm-unknown-linux-gnueabi, cross: true&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: armv7-unknown-linux-gnueabihf, cross: true&#125;</span><br><span class="line">- &#123;os: macos-latest, toolchain: stable, target: x86_64-apple-darwin, cross: false&#125;</span><br></pre></td></tr></table></figure><p>After this CI completes, we can confirm the current patch has no impact on cross-platform compilation.</p><h3 id="Summary"><a href="#Summary" class="headerlink" title="Summary"></a><strong>Summary</strong></h3><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-all-passed.png" style="zoom:50%;"/><p>Only after all the above CI tests pass is a Pull Request considered qualified and ready to merge into the main branch.</p><p>Without these automated testing CIs as safeguards, every issue would consume massive amounts of reviewer energy for verification. This model wouldn’t be sustainable and would seriously slow down product iteration and community pace.</p><p>From day one, Databend has worked hard to build a testable system. We’ve developed test-infra and the fusebot for community collaboration to accelerate Databend’s product iteration and deliver a usable Alpha version as soon as possible.</p><h3 id="References"><a href="#References" class="headerlink" title="References"></a><strong>References</strong></h3><ol><li><a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend: A Modern Real-Time Data Processing &amp; Analytics DBMS with Cloud-Native Architecture</a></li><li><a href="https://github.com/datafuselabs/databend/tree/master/.github/workflows" target="_blank" rel="noopener">Databend Github Workflows</a></li><li><a href="https://github.com/datafuselabs/test-infra" target="_blank" rel="noopener">Databend Test Infra</a></li><li><a href="https://github.com/datafuselabs/fusebots" target="_blank" rel="noopener">Databend FuseBots</a></li><li><a href="https://clickhouse.tech/docs/en/development/tests/" target="_blank" rel="noopener">ClickHouse Testing</a></li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;blockquote&gt;
&lt;p&gt;Databend is an open-source, cloud-native data warehouse built in Rust. It aims to provide lightning-fast elastic scaling and
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse（4）Databend 社区如何做测试</title>
    <link href="https://bohutang.me/2021/09/14/databend-cloud-warehouse-how-to-test/"/>
    <id>https://bohutang.me/2021/09/14/databend-cloud-warehouse-how-to-test/</id>
    <published>2021-09-14T15:41:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p>Databend 是一个使用 Rust 研发、开源的、完全面向云架构的新式数仓，致力于提供极速的弹性扩展能力，打造按需、按量的 Data Cloud 产品体验。<br>开源地址：<a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p></blockquote><p>Databend 从第一天就是开源的，测试系统也是基于开源生态所构建，使用了大量的 github CI（免费），已经支撑了我们半年来的快速迭代。</p><p>对于一个开源数据库项目，做到可测试性是加速迭代的不二法宝。一个 Pull Request (通常说的 Patch) 从提交到合并到主干分支，作为一个 Review 人员会比较关注以下几个问题:</p><ol><li>是否会导致功能不正常？</li><li>是否会影响分布式执行？</li><li>是否有跨平台编译问题？</li><li>是否会导致性能下降？</li></ol><p>本篇就从一个 Pull Request 测试周期说起，看看它从创建再到合并入主干分支，Databend 经过了哪些测试，针对上面四个问题做到心中有数，让每个 Pull Request 都有质量保障。</p><h3 id="单元测试"><a href="#单元测试" class="headerlink" title="单元测试"></a><strong>单元测试</strong></h3><p>单元测试是最小的测试单元。</p><p>我们每写一个函数都要做到可独立测试，如果这个函数有其他状态依赖，那状态也要是可以 Mock 的。</p><p>在 Databend 中，单元测试都放在一个独立的文件中，比如，x_test.rs:</p><figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#[test]</span></span><br><span class="line"><span class="function"><span class="keyword">fn</span> <span class="title">test_y</span></span>() -&gt; <span class="built_in">Result</span>&lt;()&gt; &#123;</span><br><span class="line">   ... ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>目前 Databend 有 500+ 的单元测试，并对一些状态做了全局 Mock，让开发者更加容易的编写测试用例，以从代码层面确保函数执行都符合预期，尽早的发现和解决问题。</p><p>Databend 的单元测试会在 Ubuntu 和 MacOS 两个系统上运行 （Databend 研发主要使用 Mac 和 Ubuntu 两个主力系统）。</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-unit.png" style="zoom:50%;"/><h3 id="功能测试"><a href="#功能测试" class="headerlink" title="功能测试"></a><strong>功能测试</strong></h3><p>当单元测试通过后，并不一定保证功能是正确的，因为功能通常来说是由多个函数逻辑性的贯穿而成。</p><p>功能测试又分为 Stateless 和 Stateful 两种模型，其中 Stateless 测试模型不需要加载数据集， Stateful 测试模型则需要加载预值的数据集，接下来我们着重看下 Stateless 测试模型。</p><p>Databend 参考了 ClickHouse 的做法，使用表函数 <code>numbers_mt</code> 来便捷的做 Stateless 测试。</p><p>比如这个稍微“复杂”的SQL：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">SELECT number%3 as c1, number%2 as c2 FROM numbers_mt(10000) WHERE number &gt; 2 GROUP BY number%3, number%2 ORDER BY c1, c2;</span><br></pre></td></tr></table></figure><p>它先根据条件过滤数据，然后再进行 GROUP BY 分组，最后做一个排序，这个 SQL 执行时，会涉及非常多的函数，所以我们必须有一套便捷的机制来保证多个函数组成的功能也是正确的。</p><p>Databend 是如何做的呢？</p><p>我们会先定义一个需要测试的 SQL 集，x.sql：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="built_in">number</span>%<span class="number">3</span> <span class="keyword">as</span> c1, <span class="built_in">number</span>%<span class="number">2</span> <span class="keyword">as</span> c2 <span class="keyword">FROM</span> numbers_mt(<span class="number">10000</span>) <span class="keyword">WHERE</span> <span class="built_in">number</span> &gt; <span class="number">2</span> <span class="keyword">GROUP</span> <span class="keyword">BY</span> <span class="built_in">number</span>%<span class="number">3</span>, <span class="built_in">number</span>%<span class="number">2</span> <span class="keyword">ORDER</span> <span class="keyword">BY</span> c1, c2;</span><br></pre></td></tr></table></figure><p>然后再定义一个预期的结果集，x.result：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">0  0</span><br><span class="line">0  1</span><br><span class="line">1  0</span><br><span class="line">1  1</span><br><span class="line">2  0</span><br><span class="line">2  1</span><br></pre></td></tr></table></figure><p>每次做功能测试的时候，Databend 会调用这个 x.sql 文件，然后把得到的结果集和 x.result 文件进行对比，如果有出入则报错并给出提示信息。</p><p>由于 Databend 具备分布式的 MPP 能力，所以功能测试会在单机（Standalone）和 集群（Cluster）两种模式下进行回归测试，以确保 Patch 对功能没有影响。</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-stateless.png" style="zoom:50%;"/><h3 id="性能测试"><a href="#性能测试" class="headerlink" title="性能测试"></a><strong>性能测试</strong></h3><p>当单元测试和功能测试都通过后，我们还会关注一个重要的指标：这个 Patch 是否导致性能下降？或者是一个性能优化的 Patch 提升了多少性能？</p><p>针对这个问题，Databend 使用数字来做量化，我们只需在 Pull Request 里回复: <code>/run-perf master</code> CI 会自动编译当前分支然后跑相应的性能测试，再跟 master 做对比并生成一份性能对比报告：</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-perf-report.png" style="zoom:50%;"/><p>这样，Review 人员就可以根据这个报告清晰的知道当前 Patch 对性能的影响，以确保每个 Patch 在性能上都是可控的。</p><h3 id="编译测试"><a href="#编译测试" class="headerlink" title="编译测试"></a><strong>编译测试</strong></h3><p>Databend 目标是打造一个跨平台的 Cloud Warehouse，所以要求每个 Patch 在以下几个平台都可以正常编译和工作：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: x86_64-unknown-linux-gnu, cross: false&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: aarch64-unknown-linux-gnu, cross: true&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: arm-unknown-linux-gnueabi, cross: true&#125;</span><br><span class="line">- &#123;os: ubuntu-latest, toolchain: stable, target: armv7-unknown-linux-gnueabihf, cross: true&#125;</span><br><span class="line">- &#123;os: macos-latest, toolchain: stable, target: x86_64-apple-darwin, cross: false&#125;</span><br></pre></td></tr></table></figure><p>当这个 CI 跑完后，我们可以明确的知道当前 Patch 对跨版本编译是没有影响的。</p><h3 id="小结"><a href="#小结" class="headerlink" title="小结"></a><strong>小结</strong></h3><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/test-all-passed.png" style="zoom:50%;"/><p>以上所有的 CI 测试都通过后，我们的 Pull Request 才算合格，具备合并到主干分支的条件。</p><p>如果没有这些自动化测试 CI 做保障，每个问题都会消耗 Review 人员大量的精力去做验证，这种模式肯定不可持久，严重影响产品的迭代速度，拖慢社区的节奏。</p><p>Databend 从第一天开始就在努力打造一个可测试的系统，为此我们研发了 test-infra 以及社区协作的 fusebot 机器人，以加速 Databend 产品迭代，尽快提供一个可试用的 Alpha 版本。</p><h3 id="References"><a href="#References" class="headerlink" title="References"></a><strong>References</strong></h3><ol><li><a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">Databend: A Modern Real-Time Data Processing &amp; Analytics DBMS with Cloud-Native Architecture</a></li><li><a href="https://github.com/datafuselabs/databend/tree/master/.github/workflows" target="_blank" rel="noopener">Databend Github Workflows</a></li><li><a href="https://github.com/datafuselabs/test-infra" target="_blank" rel="noopener">Databend Test Infra</a></li><li><a href="https://github.com/datafuselabs/fusebots" target="_blank" rel="noopener">Databend FuseBots</a></li><li><a href="https://clickhouse.tech/docs/en/development/tests/" target="_blank" rel="noopener">ClickHouse Testing</a></li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;blockquote&gt;
&lt;p&gt;Databend 是一个使用 Rust 研发、开源的、完全面向云架构的新式数仓，致力于提供极速的弹性扩展能力，打造按需、按量的 Data Cloud 产品体验。&lt;br&gt;开源地址：&lt;a href=&quot;https://github.com/datafus
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse (3) Datafuse Renames to Databend</title>
    <link href="https://bohutang.me/2021/09/14/datafuse-cloud-warehouse-rename-databend/"/>
    <id>https://bohutang.me/2021/09/14/datafuse-cloud-warehouse-rename-databend/</id>
    <published>2021-09-14T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p>Databend is an open-source, cloud-native data warehouse built in Rust. It aims to provide lightning-fast elastic scaling and deliver an on-demand, pay-as-you-go Data Cloud experience.<br>Open source repo: <a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p></blockquote><p>This isn’t really a technical article, but it’s important — we’ve renamed the project.</p><h3 id="Reason-for-the-Rename"><a href="#Reason-for-the-Rename" class="headerlink" title="Reason for the Rename"></a><strong>Reason for the Rename</strong></h3><p>Datafuse and the open-source project DataFusion have names that sound quite similar in English. For everyone’s future development, we’ve decided to rename the project to: Databend.</p><p>Some misunderstandings arose due to cultural differences, but once we talked things through, they were resolved. Thanks to Andy for his understanding and support. We believe both DataFusion and Databend have bright futures.</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/databend-andy-comment.png" style="zoom:50%;"/><h3 id="The-Meaning-of-Databend"><a href="#The-Meaning-of-Databend" class="headerlink" title="The Meaning of Databend"></a><strong>The Meaning of Databend</strong></h3><p>The theory of relativity is one of the 20th century’s greatest discoveries. Due to the presence of matter, time and space bend (space-time bend). It made humanity reconsider time and space. We hope that Databend’s arrival will make more people reconsider data and discover greater value.</p><h3 id="About-“Datafuse-Labs”"><a href="#About-“Datafuse-Labs”" class="headerlink" title="About “Datafuse Labs”"></a><strong>About “Datafuse Labs”</strong></h3><p>“Datafuse Labs” was founded in March 2021. It’s the team behind the open-source project Databend. The team has extensive engineering experience in cloud-native databases and is also an active contributor to the database open-source community. Currently, we have R&amp;D centers in China, the United States, and Singapore. We’re committed to becoming a leading Data Cloud infrastructure software provider.</p><h3 id="Join-Us"><a href="#Join-Us" class="headerlink" title="Join Us"></a><strong>Join Us</strong></h3><ul><li><p>Database Engineer: Responsible for Databend kernel design and development. Rich experience in distributed systems, familiar with Rust or C++, strong interest in databases. Worldwide remote work available.</p></li><li><p>Cloud Platform Engineer: Responsible for Databend Cloud product design and development. Experience with Kubernetes development preferred. Worldwide remote work available.<br>If you’re interested, send your resume to: <a href="mailto:hr@datafuselabs.com">hr@datafuselabs.com</a></p></li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;blockquote&gt;
&lt;p&gt;Databend is an open-source, cloud-native data warehouse built in Rust. It aims to provide lightning-fast elastic scaling and
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse（3）Datafuse 更名为 Databend</title>
    <link href="https://bohutang.me/2021/09/14/datafuse-cloud-warehouse-rename-databend/"/>
    <id>https://bohutang.me/2021/09/14/datafuse-cloud-warehouse-rename-databend/</id>
    <published>2021-09-14T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p>Databend 是一个使用 Rust 研发、开源的、完全面向云架构的新式数仓，致力于提供极速的弹性扩展能力，打造按需、按量的 Data Cloud 产品体验。<br>开源地址：<a href="https://github.com/datafuselabs/databend" target="_blank" rel="noopener">https://github.com/datafuselabs/databend</a></p></blockquote><p>此篇不算一个技术文章，但是比较重要，因为我们项目改名了，做个说明。</p><h3 id="项目更名原因"><a href="#项目更名原因" class="headerlink" title="项目更名原因"></a><strong>项目更名原因</strong></h3><p>Datafuse 和开源项目 DataFusion 名称在英语语境里比较接近，为了大家未来的发展，我们决定把项目更名为：Databend 。</p><p>由于文化差异导致的一些误解，大家聊开后也就化解了，感谢 Andy 的理解和支持，相信 DataFusion 和  Databend 都有着美好的前景。</p><img src="https://bohutang-1253727613.cos.ap-beijing.myqcloud.com/blog-datafuse/databend-andy-comment.png" style="zoom:50%;"/><h3 id="Databend-寓意"><a href="#Databend-寓意" class="headerlink" title="Databend 寓意"></a><strong>Databend 寓意</strong></h3><p>相对论是 20 世纪最伟大的发现之一，由于物质的存在，时间和空间会发生弯曲（space-time bend），它让人类重新审视时间与空间。我们期望 Databend 的出现，让更多人重新审视数据，发掘出更大的价值。</p><h3 id="关于-「Datafuse-Labs」"><a href="#关于-「Datafuse-Labs」" class="headerlink" title="关于 「Datafuse Labs」"></a><strong>关于 「Datafuse Labs」</strong></h3><p>「Datafuse Labs」成立于 2021 年 3 月，是开源项目 Databend 的背后团队，团队在云原生数据库领域有着丰富的工程经验，同时也是数据库开源社区活跃贡献者，目前在中国、美国、新加坡均设有研发中心，致力于成为业界领先的 Data Cloud 基础软件供应商。</p><h3 id="加入我们"><a href="#加入我们" class="headerlink" title="加入我们"></a><strong>加入我们</strong></h3><ul><li><p>数据库工程师：负责 Databend 内核设计与研发，有丰富的分布式系统经验，熟悉 Rust 或 C++ ，对数据库有着浓厚的兴趣，可 Worldwide Remote 办公。</p></li><li><p>云平台工程师：负责 Databend Cloud 产品设计与研发，有 Kubernetes 开发经验者优先，可 Worldwide Remote 办公。<br>如果对我们感兴趣，简历请投递：<a href="mailto:hr@datafuselabs.com">hr@datafuselabs.com</a></p></li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;blockquote&gt;
&lt;p&gt;Databend 是一个使用 Rust 研发、开源的、完全面向云架构的新式数仓，致力于提供极速的弹性扩展能力，打造按需、按量的 Data Cloud 产品体验。&lt;br&gt;开源地址：&lt;a href=&quot;https://github.com/datafus
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse (2) Databend Architecture Overview</title>
    <link href="https://bohutang.me/2021/08/21/datafuse-cloud-warehouse-design/"/>
    <id>https://bohutang.me/2021/08/21/datafuse-cloud-warehouse-design/</id>
    <published>2021-08-21T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.844Z</updated>
    
    <content type="html"><![CDATA[<p>Databend is an open-source, cloud-native data warehouse that provides fast elastic scaling. It combines the elasticity, simplicity, and low cost of the cloud to make building a Data Cloud easier. Databend stores data in cloud storage systems like AWS S3 and Azure Blob, allowing different compute nodes to mount the same data for high elasticity and fine-grained resource control.</p><p>Databend focuses on the following capabilities:</p><ol><li><strong>Elasticity</strong> In Databend, storage and compute resources can scale elastically on demand.</li><li><strong>Security</strong> Databend encrypts data files and network transmission end-to-end and provides role-based access control at the SQL level.</li><li><strong>Ease of use</strong> Databend is compatible with ANSI SQL and can be accessed via MySQL and ClickHouse clients, with virtually no learning curve.</li><li><strong>Cost</strong> Databend processes queries very efficiently. Users only pay for the resources they use.</li></ol><img src="https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/arch/datafuse-arch-20210817.svg" align="center" /><p>The diagram above shows Databend’s overall architecture. The system consists of three main parts: <code>Meta Service Layer</code>, <code>Compute Layer</code>, and <code>Storage Layer</code>.</p><h2 id="Meta-Service-Layer"><a href="#Meta-Service-Layer" class="headerlink" title="Meta Service Layer"></a><strong>Meta Service Layer</strong></h2><p>Meta Service is a multi-tenant, highly available distributed key-value storage service with transactional capabilities. It’s mainly used to store:</p><ul><li><code>Metadata</code>: Table metadata, index information, cluster information, transaction information, etc.</li><li><code>Administration</code>: User system, user permissions, etc.</li><li><code>Security</code>: User authentication, data encryption, etc.</li></ul><h2 id="Compute-Layer"><a href="#Compute-Layer" class="headerlink" title="Compute Layer"></a><strong>Compute Layer</strong></h2><p>The compute layer consists of multiple clusters, where different clusters can handle different workloads. Each cluster consists of multiple compute nodes. You can easily add or remove nodes or clusters for on-demand, pay-as-you-go resource management.</p><p>Compute nodes are the smallest building blocks of the compute layer. Each compute node includes the following components:</p><ul><li><strong>Planner</strong></li></ul><p>Generates an execution plan based on user-input SQL. It’s just a logical representation that can’t actually execute — it’s used to guide the orchestration and generation of the entire compute pipeline.<br>For example, the statement <code>SELECT number + 1 FROM numbers_mt(10) WHERE number &gt; 8 LIMIT 2</code><br>Execution plan:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">datafuse :) EXPLAIN SELECT number + 1 FROM numbers_mt(10) WHERE number &gt; 8 LIMIT 2</span><br><span class="line">┌─explain─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐</span><br><span class="line">│ Limit: 2                                                                                                                │</span><br><span class="line">│   Projection: (number + 1):UInt64                                                                                       │</span><br><span class="line">│     Expression: (number + 1):UInt64 (Before Projection)                                                                 │</span><br><span class="line">│       Filter: (number &gt; 8)                                                                                              │</span><br><span class="line">│         ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80] │</span><br><span class="line">└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘</span><br></pre></td></tr></table></figure><p>Reading this execution plan from bottom to top:</p><p><code>ReadDataSource</code>: Indicates which files to read data from<br><code>Filter</code>: Indicates the (number &gt; 8) expression filtering<br><code>Expression</code>: Indicates the (number + 1) expression computation<br><code>Projection</code>: Indicates which columns to query<br><code>Limit</code>: Indicates taking the first 2 rows</p><ul><li><strong>Optimizer</strong></li></ul><p>Performs rule-based optimization (A Rule Based Optimizer) on the execution plan, such as predicate pushdown or removing unnecessary columns, to make the execution plan more efficient.</p><ul><li><strong>Processors</strong></li></ul><p>Processors are the core components that execute computation logic. Based on the execution plan, processors are orchestrated into a pipeline to execute computation tasks.</p><p>The entire Pipeline is a directed acyclic graph (DAG). Each node is a processor, and each edge is formed by connecting a processor’s InPort and OutPort. Data reaches different processors for computation, then flows through edges to the next processor. Multiple processors can compute in parallel, and in cluster mode, they can execute distributedly across nodes. This is a key design for Databend’s high performance.</p><p>For example, we can use EXPLAIN PIPELINE to view:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">datafuse :) EXPLAIN PIPELINE SELECT number + 1 FROM numbers_mt(10000) WHERE number &gt; 8 LIMIT 2</span><br><span class="line">┌─explain───────────────────────────────────────────────────────────────┐</span><br><span class="line">│ LimitTransform × 1 processor                                          │</span><br><span class="line">│   Merge (ProjectionTransform × 16 processors) to (LimitTransform × 1) │</span><br><span class="line">│     ProjectionTransform × 16 processors                               │</span><br><span class="line">│       ExpressionTransform × 16 processors                             │</span><br><span class="line">│         FilterTransform × 16 processors                               │</span><br><span class="line">│           SourceTransform × 16 processors                             │</span><br><span class="line">└───────────────────────────────────────────────────────────────────────┘</span><br></pre></td></tr></table></figure><p>Again, understanding this Pipeline from bottom to top:<br><code>SourceTransform</code>: Reads data files, processed in parallel by 16 physical CPUs<br><code>FilterTransform</code>: Filters data with the (number &gt; 8) expression, processed in parallel by 16 physical CPUs<br><code>ExpressionTransform</code>: Executes the (number + 1) expression on data, processed in parallel by 16 physical CPUs<br><code>ProjectionTransform</code>: Processes data to generate final columns<br><code>LimitTransform</code>: Applies Limit 2 to data, Pipeline folds, executed by one physical CPU</p><p>Databend uses the Pipeline parallel model combined with vectorized computation to maximize CPU utilization and accelerate computation.</p><ul><li><strong>Cache</strong></li></ul><p>Compute nodes use local SSD to cache data and indexes to improve data affinity and accelerate computation.<br>Cache warming modes:</p><ul><li>LOAD_ON_DEMAND - Load indexes or data blocks on demand (default).</li><li>LOAD_INDEX - Load indexes only.</li><li>LOAD_ALL - Load all data and indexes. Suitable for smaller tables.</li></ul><h2 id="Storage-Layer"><a href="#Storage-Layer" class="headerlink" title="Storage Layer"></a><strong>Storage Layer</strong></h2><p>Databend uses the Parquet columnar storage format to store data. To speed up searching (Partition Pruning), Datafuse provides its own indexes for each Parquet file (generated based on Primary Key):</p><ul><li>min_max.idx: Parquet file’s minimum and maximum values</li><li>sparse.idx: Sparse index at N-record granularity</li></ul><p>With these indexes, we can reduce data interaction and significantly reduce computation.<br>Suppose there are two Parquet files: <code>f1</code> and <code>f2</code>.<br><code>f1</code>‘s <code>min_max.idx: [3, 5]</code>; <code>f2</code>‘s <code>min_max.idx: [4, 6]</code>. If the query condition is: <code>where x &lt; 4</code>, we only need the <code>f1</code> file, and then use the <code>sparse.idx</code> index to locate a specific data page within the <code>f1</code> file.</p><h2 id="Summary"><a href="#Summary" class="headerlink" title="Summary"></a><strong>Summary</strong></h2><p>Databend is a modern data warehouse designed entirely for cloud architecture. It decouples traditional databases and reassembles them into a Cloud Warehouse, pursuing high elasticity and low cost.</p><p>Databend’s aggregate functions are already <a href="https://datafuse.rs/overview/performance/" target="_blank" rel="noopener">very efficient</a>. Based on these efficient aggregate functions (especially Group By), we’ve implemented the model function <a href="https://datafuse.rs/sqlstatement/aggregate-functions/aggregate-windowfunnel/" target="_blank" rel="noopener">windowFunnel</a> for efficient funnel analysis computation.</p><p>Databend is currently in a rapid iteration phase. Follow us at: <a href="https://github.com/datafuselabs/databend/" target="_blank" rel="noopener">https://github.com/datafuselabs/databend/</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;Databend is an open-source, cloud-native data warehouse that provides fast elastic scaling. It combines the elasticity, simplicity, and l
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
  <entry>
    <title>Rust, Databend and the Cloud Warehouse（2）Databend 架构概览</title>
    <link href="https://bohutang.me/2021/08/21/datafuse-cloud-warehouse-design/"/>
    <id>https://bohutang.me/2021/08/21/datafuse-cloud-warehouse-design/</id>
    <published>2021-08-21T00:00:00.000Z</published>
    <updated>2026-07-03T11:49:30.848Z</updated>
    
    <content type="html"><![CDATA[<p>Databend 是一个开源的、完全面向云架构的新式数仓，它提供快速的弹性扩展能力，并结合云的弹性、简单性和低成本，使 Data Cloud 构建变得更加容易。Databend 把数据存储在像 AWS S3 ，Azure Blob 这些云上的存储系统，可以使不同的计算节点挂载同一份数据，从而做到较高的弹性，实现对资源的精细化控制。</p><p>Databend 在设计上专注以下能力：</p><ol><li><strong>弹性</strong> 在 Databend 中，存储和计算资源可以按需、按量弹性扩展。</li><li><strong>安全</strong> Databend 中数据文件和网络传输都是端到端加密，并在 SQL 级别提供基于角色的权限控制。</li><li><strong>易用</strong> Databend 兼容 ANSI SQL，并可以使用 MySQL 和 ClickHouse 客户端接入，几乎无学习成本。</li><li><strong>成本</strong> Databend 处理查询非常高效，用户只需要为使用的资源付费。</li></ol><img src="https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/arch/datafuse-arch-20210817.svg" align="center" /><p>上图是 Databend 的整体架构图，整个系统主要由三大部分组成：<code>Meta service Layer</code>、<code>Compute Layer</code> 和 <code>Storage Layer</code>。</p><h2 id="Meta-Service-Layer"><a href="#Meta-Service-Layer" class="headerlink" title="Meta Service Layer"></a><strong>Meta Service Layer</strong></h2><p>Meta Service 是一个多租户、高可用的分布式 key-value 存储服务，具备事务能力，主要用于存储：</p><ul><li><code>Metadata</code> : 表的元信息、索引信息、集群信息、事务信息等。</li><li><code>Administration</code>：用户系统、用户权限等信息。</li><li><code>Security</code> ：用户登录认证、数据加密等。</li></ul><h2 id="Compute-Layer"><a href="#Compute-Layer" class="headerlink" title="Compute Layer"></a><strong>Compute Layer</strong></h2><p>计算层由多个集群（cluster）组成，不同集群可以承担不同的工作负载，每个集群又有多个计算节点（node）组成，你可以轻松的添加、删除节点或集群，做到资源的按需、按量管理。</p><p>计算节点是计算层的最小构成单元，其中每个计算节点包含以下几个组件：</p><ul><li><strong>执行计划 （Planner）</strong></li></ul><p>根据用户输入的 SQL 生成执行计划，它只是个逻辑表达，并不能真正的执行，而是用于指导整个计算流水线（Pipeline）的编排与生成。<br>比如语句 <code>SELECT number + 1 FROM numbers_mt(10) WHERE number &gt; 8 LIMIT 2</code><br>执行计划：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">datafuse :) EXPLAIN SELECT number + 1 FROM numbers_mt(10) WHERE number &gt; 8 LIMIT 2</span><br><span class="line">┌─explain─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐</span><br><span class="line">│ Limit: 2                                                                                                                │</span><br><span class="line">│   Projection: (number + 1):UInt64                                                                                       │</span><br><span class="line">│     Expression: (number + 1):UInt64 (Before Projection)                                                                 │</span><br><span class="line">│       Filter: (number &gt; 8)                                                                                              │</span><br><span class="line">│         ReadDataSource: scan partitions: [1], scan schema: [number:UInt64], statistics: [read_rows: 10, read_bytes: 80] │</span><br><span class="line">└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘</span><br></pre></td></tr></table></figure><p>这个执行计划自下而上分别是 ：</p><p><code>ReadDataSource</code>：表示从哪些文件里读取数据<br><code>Filter</code>: 表示要做 (number &gt; 8) 表达式过滤<br><code>Expression</code>: 表示要做 (number + 1) 表达式运算<br><code>Projection</code>: 表示查询列是哪些<br><code>Limit</code>: 表示取前 2 条数据</p><ul><li><strong>优化器 （Optimizer）</strong></li></ul><p>对执行计划做一些基于规则的优化（A Rule Based Optimizer）, 比如做一些谓词下推或是去掉一些不必要的列等，以使整个执行计划更优。</p><ul><li><strong>处理器 （Processors）</strong></li></ul><p>处理器（Processor）是执行计算逻辑的核心组件。根据执行计划，处理器们被编排成一个流水线（Pipeline），用于执行计算任务。</p><p>整个 Pipeline 是一个有向无环图，每个点是一个处理器，每条边由处理器的 InPort 和 OutPort 相连构成，数据到达不同的处理器进行计算后，通过边流向下一个处理器，多个处理器可以并行计算，在集群模式下还可以跨节点分布式执行，这是 Databend 高性能的一个重要设计。</p><p>例如，我们可以通过 EXPLAIN PIPELINE 来查看：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">datafuse :) EXPLAIN PIPELINE SELECT number + 1 FROM numbers_mt(10000) WHERE number &gt; 8 LIMIT 2</span><br><span class="line">┌─explain───────────────────────────────────────────────────────────────┐</span><br><span class="line">│ LimitTransform × 1 processor                                          │</span><br><span class="line">│   Merge (ProjectionTransform × 16 processors) to (LimitTransform × 1) │</span><br><span class="line">│     ProjectionTransform × 16 processors                               │</span><br><span class="line">│       ExpressionTransform × 16 processors                             │</span><br><span class="line">│         FilterTransform × 16 processors                               │</span><br><span class="line">│           SourceTransform × 16 processors                             │</span><br><span class="line">└───────────────────────────────────────────────────────────────────────┘</span><br></pre></td></tr></table></figure><p>同样，理解这个 Pipeline 我们自下而上来看：<br><code>SourceTransform</code>：读取数据文件，16 个物理 CPU 并行处理<br><code>FilterTransform</code>：对数据进行 (number &gt; 8) 表达式过滤，16 个物理 CPU 并行处理<br><code>ExpressionTransform</code>：对数据进行 (number + 1) 表达式执行，16 个物理 CPU 并行处理<br><code>ProjectionTransform</code>：对数据处理生成最终列<br><code>LimitTransform</code>：对数据进行 Limit 2 处理，Pipeline 进行折叠，由一个物理 CPU 来执行</p><p>Databend 通过 Pipeline 并行模型，并结合向量计算最大限度的去压榨 CPU 资源，以加速计算。</p><ul><li><strong>缓存 (Cache)</strong></li></ul><p>计算节点使用本地 SSD 缓存数据和索引，以提高数据亲和性来加速计算。<br>缓存的预热方式有：</p><ul><li>LOAD_ON_DEMAND - 按需加载索引或数据块（默认）。</li><li>LOAD_INDEX - 只加载索引。</li><li>LOAD_ALL - 加载全部的数据和索引，对于较小的表可以采取这种模式。</li></ul><h2 id="Storage-Layer"><a href="#Storage-Layer" class="headerlink" title="Storage Layer"></a><strong>Storage Layer</strong></h2><p>Databend 使用 Parquet 列式存储格式来储存数据，为了加快查找（Partition Pruning），Datafuse 为每个 Parquet 提供了自己的索引（根据 Primary Key 生成）：</p><ul><li>min_max.idx Parquet 文件 minimum 和 maximum 值</li><li>sparse.idx 以 N 条记录为颗粒度的稀疏索引</li></ul><p>通过这些索引， 我们可以减少数据的交互，并使计算量大大减少。<br>假设有两个Parquet 文件：<code>f1</code>, <code>f2</code>。<br><code>f1</code> 的 <code>min_max.idx: [3, 5]</code> ；<code>f2</code> 的 <code>min_max.idx: [4, 6]</code> 。如果查询条件为：<code>where x &lt; 4</code> ， 我们只需要 <code>f1</code> 文件就可以，再根据 <code>sparse.idx</code> 索引定位到 <code>f1</code> 文件中的某个数据页。</p><h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a><strong>总结</strong></h2><p>Databend 是一个完全面向云架构而设计的新式数仓，它把传统数据库进行解耦，再根据需求组装出一个 Cloud Warehouse，以追求高弹性、低成本为宗旨。</p><p>Databend 目前的聚合函数已经<a href="https://datafuse.rs/overview/performance/" target="_blank" rel="noopener">非常高效</a>，基于这些高效的聚合函数（尤其是 Group By），我们实现了模型函数 <a href="https://datafuse.rs/sqlstatement/aggregate-functions/aggregate-windowfunnel/" target="_blank" rel="noopener">windowFunnel</a>，用于漏洞模型的高效计算。</p><p>Databend 正处于高速迭代期，欢迎关注我们: <a href="https://github.com/datafuselabs/databend/" target="_blank" rel="noopener">https://github.com/datafuselabs/databend/</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;Databend 是一个开源的、完全面向云架构的新式数仓，它提供快速的弹性扩展能力，并结合云的弹性、简单性和低成本，使 Data Cloud 构建变得更加容易。Databend 把数据存储在像 AWS S3 ，Azure Blob 这些云上的存储系统，可以使不同的计算节点挂
      
    
    </summary>
    
    
    
      <category term="databend" scheme="https://bohutang.me/tags/databend/"/>
    
      <category term="cloud warehouse" scheme="https://bohutang.me/tags/cloud-warehouse/"/>
    
  </entry>
  
</feed>
