<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Disco Chess</title>
    <description>The latest articles on DEV Community by Disco Chess (@discochess).</description>
    <link>https://dev.to/discochess</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3711693%2F7eff34cf-0294-4e89-b964-7242d5503224.png</url>
      <title>DEV Community: Disco Chess</title>
      <link>https://dev.to/discochess</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/discochess"/>
    <language>en</language>
    <item>
      <title>How We Index 342 Million Chess Positions for Millisecond Lookups</title>
      <dc:creator>Disco Chess</dc:creator>
      <pubDate>Thu, 15 Jan 2026 00:56:58 +0000</pubDate>
      <link>https://dev.to/discochess/how-we-index-342-million-chess-positions-for-millisecond-lookups-4lce</link>
      <guid>https://dev.to/discochess/how-we-index-342-million-chess-positions-for-millisecond-lookups-4lce</guid>
      <description>&lt;p&gt;&lt;a href="https://www.discochess.com" rel="noopener noreferrer"&gt;Disco Chess&lt;/a&gt; is a chess tactics trainer built on the Woodpecker Method - solving the same puzzles repeatedly until pattern recognition becomes automatic. One feature scans your games from Lichess and Chess.com to find positions where you missed a winning move, then drills you on those patterns until they stick.&lt;/p&gt;

&lt;p&gt;To find missed tactics, we need Stockfish evaluations for every position. At depth 36, that's seconds per position. A 40-move game has 80+ positions. The compute costs were adding up fast.&lt;/p&gt;

&lt;p&gt;Lichess publishes their &lt;a href="https://database.lichess.org/#evals" rel="noopener noreferrer"&gt;entire evaluation database&lt;/a&gt; monthly - 342 million positions already analyzed. If we could look up positions fast enough, we'd only need Stockfish for positions that aren't already there.&lt;/p&gt;

&lt;p&gt;But how do you query 342 million positions in milliseconds?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Insight: Material Rarely Changes
&lt;/h2&gt;

&lt;p&gt;In a typical chess game, captures are rare. You might go 8-10 moves between captures - that's 8-10 consecutive positions with identical material.&lt;/p&gt;

&lt;p&gt;If we group positions by material configuration, consecutive positions in a game land in the same group. Load that group once, cache hit for the next several lookups.&lt;/p&gt;

&lt;p&gt;We call these groups "shards." Each shard contains all positions with a specific material signature. 8,359 shards containing 342 million positions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proof: 10,000 Magnus Carlsen Games
&lt;/h2&gt;

&lt;p&gt;We ran 10,268 Magnus Carlsen games (873,418 positions) through a cache simulator:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Cache Hit Rate (LRU-100)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Material-based&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;93.42%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hash-based&lt;/td&gt;
&lt;td&gt;2.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Material-based sharding wins by 91 percentage points.&lt;/p&gt;

&lt;p&gt;Material changes on average every 8.7 positions. With a 100-shard LRU cache, we hit 93% of the time. Hash-based sharding scatters consecutive positions randomly - destroying locality entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://discochess.com/blog/engineering/chess-evaluation-database" rel="noopener noreferrer"&gt;Read the full post →&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/discochess/stockpile" rel="noopener noreferrer"&gt;stockpile on GitHub&lt;/a&gt; (MIT license)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://database.lichess.org/#evals" rel="noopener noreferrer"&gt;Lichess Evaluation Database&lt;/a&gt; (CC0)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>lichess</category>
      <category>opensource</category>
      <category>database</category>
    </item>
  </channel>
</rss>
