Poor performance when "drawing" many instances containing hidden layers

Open
#2,227 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@klayoutmatthias is already working on this.

Since Nov 25, 2025.

Assessment

This issue has not been assessed yet.

Description

enhancement

Layouts containing a large number of instances can be very slow to redraw (and cause freezes / crashes), even in cases where those instances contain only a single, hidden, layer.

I've attached a file (tiles.gds.gz) that can help to show the effect -- to reproduce, open the file, hide layer 1/0, show the full hierarchy (to avoid drawing cell boxes), then zoom in and out and watch the other layers get drawn one-by-one.

The effect goes away if you flatten the layout -- based on this, I assume the drawing code is visiting each instance (but drawing nothing as the layer is hidden). Is there an easy opportunity to do some caching (e.g. "nothing to draw for this cell, skip its instances"), or are instances stored in a way that wouldn't help?

Happy to try to build something myself, but figured I'd ask before getting too deep into the code (so far, some quick profiling pointed me towards layRedrawThreadWorker.cc).

Dominant language
C++
Stars
1.2k
Forks
305
Avg merge
3d 2h
Merged PRs (30d)
11

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from KLayout/klayout

All issues in KLayout/klayout

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.