[scheduler] Improve timeline event layout performance - #23364
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
a4e4ee0 to
b8bbeae
Compare
b8bbeae to
967efd8
Compare
There was a problem hiding this comment.
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
computeOccurrencesWithTimelinePositionhelper 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
left a comment
There was a problem hiding this comment.
The differential test is 🥇
Changelog
maxSpanbehavior.Local old/new comparison using the benchmark fixtures:
Tests:
Timeline-position suite: 14 passed
@mui/x-scheduler-internalsTypeScript checkESLint and Prettier checks for changed files
I have followed (at least) the PR section of the contributing guide.