# 160MBのテンソルを捨てて3.1〜20倍高速化：tsbootstrapが実践した「バイトを数える」最適化

Original title: Count the Bytes, Not the FLOPs

> Hacker News story 48907876 · language: ja · submitted 2026-07-14
> Web version: https://zeli.app/ja/story/48907876
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 10 · by [sgilda](<https://news.ycombinator.com/user?id=sgilda>) · 💬 1
[original](<https://thepragmaticquant.com/why-we-stopped-materializing-arrays/>) · [HN discussion](<https://news.ycombinator.com/item?id=48907876>)

## Summary

Pythonの時系列ブートストラップライブラリtsbootstrapは、全リプリケートを一括でメモリに展開する実装が原因で、競合ライブラリarchに大幅な性能差をつけられていた。原因はFLOPsではなくメモリ帯域にあり、リプリケートごとに融合カーネルで処理するストリーミング方式へ書き換えたところ、ベンチマークで3.1倍から20倍の高速化を達成。メモリ使用量も最大97%削減された。この設計思想は、大規模言語モデルの学習で主流となったFlashAttentionの「大きな中間行列を実体化しない」という原理と共通する。

## Key quote

> CPUコアはレジスタに保持したデータでしか計算できない。レジスタを自分の手と考えよう。その後ろにはL1キャッシュ（手を伸ばせば届く机）、L2（背後にある棚）、L3（共有のキャビネット）があり、その先のDRAM（メインメモリ）は通りを挟んだ倉庫で、どの段階よりも大きく遅い。ハードウェアはその階層構造をランタイムから隠すことはない。隠すのはソースコードからだけだ。

---

## Cite

- Page: https://zeli.app/ja/story/48907876
- Date: 2026-07-14
- Source: thepragmaticquant.com (https://thepragmaticquant.com/why-we-stopped-materializing-arrays/)
- Hacker News: https://news.ycombinator.com/item?id=48907876

## Other languages

- en: https://zeli.app/story/48907876 · markdown: https://zeli.app/story/48907876.md
- zh: https://zeli.app/zh/story/48907876 · markdown: https://zeli.app/zh/story/48907876.md
- ko: https://zeli.app/ko/story/48907876 · markdown: https://zeli.app/ko/story/48907876.md
- de: https://zeli.app/de/story/48907876 · markdown: https://zeli.app/de/story/48907876.md
- es: https://zeli.app/es/story/48907876 · markdown: https://zeli.app/es/story/48907876.md
