---
title: "TreeWalker: Avoiding redundant work across rows and trees"
description: "TreeWalker is an open-source Rust inference engine for gradient-boosted tree ensembles that evaluates groups of related rows together, resolving decisions on features that are constant across the group once and reusing prepared predicate masks for tests repeated across trees."
url: "https://swe.quest/articles/treewalker-avoiding-redundant-work-across-rows-and-trees-93fac88bd07c564b"
canonical: "https://shopify.engineering/treewalker"
source: "Shopify Engineering"
published: "2026-12-02"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 10
tags: ["inference","performance","rust","machine-learning","algorithms"]
---

# TreeWalker: Avoiding redundant work across rows and trees

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2026-12-02, 10 min read, Deep dive. Original: [https://shopify.engineering/treewalker](https://shopify.engineering/treewalker)

## Summary

TreeWalker is an open-source Rust inference engine for gradient-boosted tree ensembles that evaluates groups of related rows together, resolving decisions on features that are constant across the group once and reusing prepared predicate masks for tests repeated across trees. It uses per-row bitmasks, sorted threshold sweeps and a cache-friendly node layout. An "unsplit" shortcut keeps a subset together when every active row takes the same branch. On Shopify's discrete-time hazard delivery-date model it scored 3.96× faster than the existing evaluator with identical results. Public benchmarks show 7.7–9.1× speedups at 104–128-row groups, but setup costs make it lose on many small-group configurations, and compiled engines like TL2cgen still win some cases.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)

## Prerequisites

- gradient boosted decision trees
- LightGBM or XGBoost inference ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- CPU cache and branching basics ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))

## Keywords

TreeWalker, LightGBM, XGBoost, TL2cgen, lleaves, partial evaluation, Shopify

## Related posts

- [Building world-class product search at Shopify: Where C++ excellence meets ML innovation](https://swe.quest/articles/building-world-class-product-search-at-shopify-where-c-excellence-meets-ml-0dc65e1a92fe63ec.md): Shopify Engineering · 2025-11-12 · Easy · 5 min read · Search, Performance engineering, C & C++, Machine learning, Language design
  Shopify's product search runs ML ranking models (transformers, neural rankers, CatBoost/LightGBM) at native C++ speed through RankFlow, a Python-like ranking DSL, and TurboDSL, its execution engine.
- [Introducing Velox: An open source unified execution engine](https://swe.quest/articles/introducing-velox-an-open-source-unified-execution-engine-d191dd46ed8f465e.md): Meta Engineering · 2023-03-09 · Hard · 8 min read · Query engines, Analytics & OLAP, C & C++, Performance engineering, Open source
  Velox is Meta's open source C++ execution engine that unifies the data-plane components (expression evaluation, aggregation, joins, sorting, I/O, resource management) shared by engines like Presto, Spark and PyTorch's TorchArrow.
- [What the interns have wrought, 2025 edition](https://swe.quest/articles/what-the-interns-have-wrought-2025-edition-eda7f47e78fb3ca5.md): Jane Street Tech Blog · 2025-08-27 · Hard · 12 min read · Functional programming, Memory management, Query engines, Type systems, Performance engineering
  Jane Street's 2025 intern projects include an index-aware evaluator for JSQL, the company's internal SQL dialect, which over-approximates key ranges from WHERE clauses and specializes execution to Map, Hashtbl or multi-index containers, giving ~700x and ~30x speedups on 3.8M-row benchmarks.
- [Introducing TabFM: A zero-shot foundation model for tabular data](https://swe.quest/articles/introducing-tabfm-a-zero-shot-foundation-model-for-tabular-data-3b60f0bd6faee92a.md): Google Research · 2026-06-30 · Easy · 5 min read · Machine learning, Model training, Analytics & OLAP
  TabFM is a foundation model that treats tabular classification and regression as in-context learning, so it predicts on an unseen table in a single forward pass with no training, hyperparameter tuning or feature engineering.
- [Scaling Model Evaluation at Pinterest with Ray (Part 4)](https://swe.quest/articles/scaling-model-evaluation-at-pinterest-with-ray-part-4-ba1e956bb72b960e.md): Pinterest Engineering · 2026-11-04 · Medium · 11 min read · ML platforms, Evaluation, Recommendations & ranking, Data pipelines, Python
  Pinterest fused model-evaluation metric computation into its Ray batch inference jobs, removing the separate Spark/Ray metrics job and the write-predictions-to-S3-then-reread handoff.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
