Skip to content

Project heading tree levels in linear time - #593

Merged
suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/linear-heading-tree-projection
Nov 28, 2026
Merged

suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/linear-heading-tree-projection

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

Project heading tree levels
  Collect the first depth-first level for each heading ID
  Map candidate rows to levels and batch the write
  Preserve body rows, row order, and original heading text

Evidence

  • Before. A Linux Docker run with 70,000 explicit Markdown headings spent 169.86 seconds in tree projection. The Worker health probe reported 1,347 stale-heartbeat failures at the 45-second threshold.
  • After. The same fixture projected all 70,000 heading IDs and levels in 0.23 seconds. All 247 health probes passed. The oldest observed heartbeat was 10.18 seconds.
  • The regression test catches repeated ID searches without a wall-clock threshold. A second test covers pruned children, duplicate IDs, and untouched body rows.
  • All 16 targeted tests, Ruff, and Pyright on the changed Worker module passed.

Merge Danger

Two-way door. A revert restores the prior projection code. The change requires no data migration.

Blast radius. The shared Worker heading tree used by Markdown and DOCX.

Repeated ID searches in the heading tree projection starved the worker heartbeat on dense Markdown. Collect the first depth-first level per ID once and apply the levels in a single DataFrame write.
@suguanYang
suguanYang merged commit dc58b0d into main Nov 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant