Skip to content

[scheduler] Improve timeline event layout performance - #23364

Merged
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:perf/scheduler-lane-layout
Aug 24, 2026
Merged

[scheduler] Improve timeline event layout performance#23364
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:perf/scheduler-lane-layout

Conversation

@flaviendelangle

Copy link
Copy Markdown
Member

Changelog

  • Replace pairwise timeline conflict construction with a sweep-line lane allocator backed by heaps and a Fenwick tree.
  • Reduce dense layout work from quadratic conflict storage and traversal to O(n log n), while preserving lane reuse and maxSpan behavior.
  • Add randomized differential tests against the previous layout semantics and a dense 1,000-event case.
  • Add Vitest benchmarks for fully overlapping and rolling-overlap workloads.

Local old/new comparison using the benchmark fixtures:

Scenario Previous New
2,000 fully overlapping events ~550 ms ~2.3 ms
10,000 rolling events, 100 concurrent ~156 ms ~10.2 ms

Tests:

  • Timeline-position suite: 14 passed

  • @mui/x-scheduler-internals TypeScript check

  • ESLint and Prettier checks for changed files

  • I have followed (at least) the PR section of the contributing guide.

@flaviendelangle flaviendelangle self-assigned this Aug 18, 2026
@flaviendelangle flaviendelangle added performance type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: scheduler Changes related to the scheduler. labels Aug 18, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23364--material-ui-x.netlify.app/
QR code for https://deploy-preview-23364--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 🔺+253B(+0.07%) 🔺+197B(+0.19%)
@mui/x-scheduler-premium 🔺+235B(+0.04%) 🔺+172B(+0.11%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves timeline event layout performance in @mui/x-scheduler-internals by replacing the previous quadratic conflict-based positioning with an O(n log n) lane allocator (heap-based sweep line plus a Fenwick/Binary Indexed Tree for span constraints). The change is then consumed by premium timeline UI code paths that need lane counts / lane lookups, and is validated via new differential tests and benchmarks.

Changes:

  • Refactored timeline occurrence positioning to a sweep-line allocator with heap reuse and optional Fenwick tree support for maxSpan >= 2.
  • Exposed a pure computeOccurrencesWithTimelinePosition helper and updated call sites to use the new pure helpers (dropping adapter dependency where it’s no longer needed).
  • Added randomized differential tests vs. a quadratic reference implementation, plus a dense-case test and Vitest benchmarks; excluded bench files from build outputs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/x-scheduler-premium/src/event-timeline-premium/content/timeline-dependency-arrows/dependencyArrowGeometry.ts Updates lane lookup computation to use the new adapter-free first-index lookup helper.
packages/x-scheduler-premium/src/event-timeline-premium/content/EventTimelinePremiumContent.tsx Uses the adapter-free lane count helper and removes adapter from memo deps accordingly.
packages/x-scheduler-internals/tsconfig.build.json Excludes *.bench.ts* from build tsconfig inputs.
packages/x-scheduler-internals/src/use-event-occurrences-with-timeline-position/useEventOccurrencesWithTimelinePosition.ts Replaces conflict graph layout with heap + Fenwick allocator; adds pure compute helper APIs.
packages/x-scheduler-internals/src/use-event-occurrences-with-timeline-position/useEventOccurrencesWithTimelinePosition.test.ts Adds deterministic randomized differential tests, a lane-reuse span test, and a dense 1,000-case test.
packages/x-scheduler-internals/src/use-event-occurrences-with-timeline-position/useEventOccurrencesWithTimelinePosition.bench.ts Adds Vitest benchmarks for dense overlap and rolling-overlap scenarios.
packages/x-scheduler-internals/package.json Excludes bench files from build and adds a bench:jsdom script.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rita-codes rita-codes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The differential test is 🥇

@flaviendelangle
flaviendelangle merged commit ee93a81 into mui:master Aug 24, 2026
22 checks passed
@flaviendelangle
flaviendelangle deleted the perf/scheduler-lane-layout branch August 24, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance scope: scheduler Changes related to the scheduler. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants