# Performance

> How fast the Gantt schedules large projects, how incremental rescheduling and virtualization work, and how to keep big programmes responsive.

Construction programmes, product launches and IT rollouts often have thousands of tasks. The Gantt is built for that size: scheduling is incremental, and only what is on screen is rendered.

## Scheduling speed

In the package's own words: **"an edit reschedules only what it affects. 5,000 tasks with 8,000 links schedule in about 80 ms, and a single edit takes about 12 ms."**

- A **full** schedule (on load, `setTasks`, `fromJSON`, `fromMSProjectXML`, `schedule()`) runs the forward and backward pass over every task.
- An **incremental** schedule (after a drag, a grid edit or an API edit) recomputes the changed task, the tasks downstream of it and the summaries above them, and leaves the rest alone.

`tasksScheduled` reports the time each run took in `ms`, so you can watch it in production:

```ts
gantt.on('tasksScheduled', ({ ms, changed }) => {
  if (ms > 50) telemetry.record('gantt.slow_schedule', { ms, changed: changed.length });
});
```

The package's performance tests guard these numbers with generous limits on a 5,000-task, 8,000-link project: full scheduling, early and late edits, undo, adding a link, the critical path, MS Project export and import.

## Virtualization

Rows, bars and links are virtualized: only the rows in view, plus `overscanRows` above and below (default 6), and the part of the timeline in view, plus `overscanPx` on each side (default 300 pixels), are in the DOM. Scrolling only updates the rows, bars and links that enter or leave the view. The task grid uses the virtualized Birch UI Grid core.

## Bundle size

About 42 KB minified and gzipped, styles included, and about 79 KB together with `@birchui/core`, `@birchui/license` and the time axis engine from `@birchui/scheduler`.

## Guidelines for large projects

- **Load once.** Pass all tasks and links at creation, or with `setTasks` and `fromJSON`, instead of calling `addTask` in a loop; each API call is a scheduling run and an undo step.
- **Batch on the server.** In the [headless engine](https://docs.birchui.com/gantt/headless.md#batch-changes), `transaction()` groups many edits into one scheduling run.
- **Keep renderers cheap.** Custom column `renderer` functions and a `taskTooltip` function run for rows as they scroll into view; avoid expensive lookups in them.
- **Pick a coarse preset for long programmes.** A five-year plan at `'weekAndDay'` is a very wide timeline; `'weekAndMonth'` or `'monthAndQuarter'` keeps it readable and cheap.
- **Use `autoSchedule: false`** for what-if sessions where people rearrange many tasks before rescheduling once with `schedule()`.
- **Listen narrowly.** Save from `tasksScheduled` with the `changed` ids rather than serializing the whole project after every edit.

## Next steps

- [Headless engine](https://docs.birchui.com/gantt/headless.md) for server-side scheduling.
- [Scheduling](https://docs.birchui.com/gantt/scheduling.md#propagation-and-auto-scheduling) for propagation.
