Ray's Knowledge Base
Unlock

A dictionary-only string scan was slower because kernels flatten non-flat columns again

PitfallVerified 2 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A scan that kept string columns as dictionary codes was slower than the flat scan: collect +8%, group-by +11%, and no memory gain.

Cause#

About 45 materialize sites and 104 is_flat checks flatten any non-flat column again, so the codes were expanded back to strings downstream.

Fix#

A new string layout pays only when the kernels keep it. The plan in docs/plans/2026-10-02-zero-copy-strings.md is a View plus a Dictionary over an intern arena, with kernels that peel dictionaries.

Evidence#

Measured in dftracer-utils on 2026-10-02 (collect +8%, group-by +11%). The counts come from the session notes.

Also found by searching

  • dictionary-encoded string scan is slower than the flat scan
  • string columns as codes gave no memory gain and slower collect and group-by
  • why do non-flat columns get flattened again in kernels
  • when does a new string column layout pay off