I build KulmanLab CAD, a free 2D CAD that runs in the browser. It has no backend, it opens DXF files, and everything is drawn with plain Canvas 2D.
CAD files are a good stress test: hundreds of thousands of lines, arcs, text labels and hatches, and a user who expects panning and zooming to stay smooth.
Here is what I learned, written as problems and fixes you can reuse in any canvas app: a map, a diagram editor, a node graph or a chart.
The timings are my own measurements, mostly in a headless browser. Compare the before and after, and don't treat them as universal numbers.
Problem: working out "is it visible?" was the slow part
Everyone's first optimization is to skip off-screen objects. It works, but you need each object's bounding box to do it.
For lines that's nothing. For text you have to measure it on the canvas. On 100,000 objects, getting the bounds cost about 70 ms per frame.
Fix: cache them.…