Skip to content

Bind netlist cluster tables by reference instead of copying them - #2510

Merged
klayoutmatthias merged 1 commit into
KLayout:masterfrom
nikosavola:pr-l2n-copies
Oct 17, 2026
Merged

klayoutmatthias merged 1 commit into
KLayout:masterfrom
nikosavola:pr-l2n-copies

Conversation

@nikosavola

Copy link
Copy Markdown
Contributor

Some places in LayoutToNetlist, the device extractor and the soft connection code stored the result of clusters_per_cell, cluster_by_id or the soft connection getters in an auto variable. These functions return references, so auto made a full copy of the cluster table of a cell, or of a cluster, on every call. They now use a const reference. Nothing else changes.

Pin and terminal shape queries gain the most, since they copied the cluster table of the cell for every pin:

case before ms after ms speedup
pin_shapes_query/32 9.01 0.865 10.4x
pin_shapes_query/128 119 3.53 33.7x
net_shapes_query/128 5.12 5.09 1.01x
netlist_extraction/128 22.9 22.9 1.00x

Measured on a Xeon Gold 6148 with g++ -O2. The benchmark is not part of this PR.

- `clusters_per_cell`, `cluster_by_id` and the soft connection getters return references, but `auto` copied the whole per-cell cluster table or cluster on every pin, terminal and net shape query
@klayoutmatthias

Copy link
Copy Markdown
Collaborator

That's redundant with #2496, but fixes more places.

@klayoutmatthias
klayoutmatthias merged commit 7f284af into KLayout:master Oct 17, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants