# Layer-filtering benchmarks
For a synthetic 1 GiB OASIS file with 1,036,400 paths, filtering during a Rust read took **2.691 s and 51.3 MiB peak RSS**. Loading and then filtering in the same Rust implementation took **5.245 s and 3,211.0 MiB**. Both retained 10,364 attributed paths. Increasing input size to 10 GiB with the same selected output gave 29.676 s and 50.4 MiB for filtering during read. These measurements compare two layouttk operations on a specified workload.
## Inputs
- **Public design.** The IHP SG13G2 I/O library from OpenROAD-flow-scripts is 71,424,000 bytes. It contains 47 definitions and 22 roots, 1,113,991 polygons, one path, 1,226 texts and 78 references. Selecting 1/0 retains 268 polygons and 78 references. SHA-256 is `4281a855377b6a1ca46356e9391258dc14e8efc3b8051a65befc0fe9db3c7825`. [Pinned IHP file](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/blob/8ba54e723175036fbe1a3541c7a1141cfc4f83b9/flow/platforms/ihp-sg13g2/gds/sg13g2_io.gds)
- **Synthetic designs.** Each OASIS PATH has 129 integer vertices, flush ends and a width of 4 DBU on a 1 nm grid. Each selected path carries a RUN property with the integer 42 and ASCII string `mask`. Each compressed block contains 100 paths with level-0 DEFLATE. The small dataset retains one path per block. The large dataset adds nine equally sized blocks of discarded paths for each original block. These are single-cell, repeated workloads without placements. Real designs can have different compression ratios, hierarchies and metadata.
| Dataset | Input bytes | Stored input elements | Retained elements | Output OASIS bytes |
| --- | ---: | ---: | ---: | ---: |
| IHP GDSII | 71,424,000 | 1,115,296 | 346 | 8,174 |
| Synthetic 1 GiB | 1,073,669,239 | 1,036,400 | 10,364 | 150,175 |
| Synthetic 10 GiB | 10,736,689,735 | 10,364,000 | 10,364 | 150,175 |
## Results
Medians over three fresh processes per operation, with one sequential warmup read. Throughput uses on-disk input bytes. Measurements were made on November 28, 2026 on an Apple M4 Mac mini with 24 GiB unified memory, local APFS SSD, macOS 26.6.2, Rust 1.100.1 and a release build of the 0.1.0 development tree. The Python runs used CPython 3.11.15, maturin 1.16.0 and the installed arm64 wheel.
| Input | Operation | Seconds | MiB/s | Peak RSS (MiB) |
| --- | --- | ---: | ---: | ---: |
| IHP GDSII | Rust empty selection | 0.106 | 640.4 | 2.0 |
| IHP GDSII | Rust filter during read | 0.107 | 637.6 | 2.4 |
| IHP GDSII | Python filter during read | 0.108 | 632.0 | 25.7 |
| IHP GDSII | Rust filter and write OASIS | 0.107 | 636.5 | 2.4 |
| IHP GDSII | Rust full read | 0.117 | 583.6 | 211.7 |
| IHP GDSII | Rust load then filter | 0.134 | 507.7 | 211.8 |
| 1 GiB OASIS | Rust empty selection | 3.069 | 333.7 | 2.5 |
| 1 GiB OASIS | Rust filter during read | 2.691 | 380.4 | 51.3 |
| 1 GiB OASIS | Python filter during read | 2.907 | 352.3 | 74.1 |
| 1 GiB OASIS | Rust filter and write OASIS | 3.136 | 326.5 | 51.0 |
| 1 GiB OASIS | Rust full read | 4.049 | 252.9 | 3432.9 |
| 1 GiB OASIS | Rust load then filter | 5.245 | 195.2 | 3211.0 |
| 10 GiB OASIS | Rust empty selection | 31.369 | 326.4 | 2.4 |
| 10 GiB OASIS | Rust filter during read | 29.676 | 345.0 | 50.4 |
| 10 GiB OASIS | Python filter during read | 31.256 | 327.6 | 71.0 |
| 10 GiB OASIS | Rust filter and write OASIS | 33.435 | 306.2 | 50.7 |
Read timing stops when the selected model is available. Conversion also times encoding, compression and replacement of the destination. RSS is the peak over the whole process, including serialization for later verification. The OS manages its file cache. Each decode used one worker. Full loading of the 10 GiB case was omitted on this machine. Its coordinates alone would take about 19.9 GiB and the configured retained-data budget was 4 GiB.
gdstk 1.0.2 checked polygon edges, reference targets, transforms and arrays in the IHP output. Its SHA-256 was `34d32a9d04cf45da662cd6e053ebee90fa1b9354ba746055b70e159da6a96950`. Both synthetic outputs had SHA-256 `f65bfef81e80bf5bc06d60df7a658d1f36393832f0d4c26876d740a00d09d4e6`. The verifier checked all selected paths, coordinates, widths, layers and property values.
## Reproduce
On Linux or macOS, unpack the Python source distribution or use a source checkout. Install Rust, create a Python environment and run the commands below from the project root. Reserve at least 12 GiB of scratch space for a full run. Setup, input generation and independent verification are outside the timed operation. Each JSON line includes the raw time and RSS samples.
```sh
python3.11 -m venv .venv-bench
. .venv-bench/bin/activate
python -m pip install 'maturin==1.16.0' 'gdstk==1.0.2'
maturin build --release --locked --out /tmp/layouttk-bench-wheel
python -m pip install --no-deps --force-reinstall /tmp/layouttk-bench-wheel/layouttk-*.whl
python scripts/benchmark_layouts.py --rounds 3 > /tmp/layouttk-bench.jsonl
```
For a short validation run, use `python scripts/benchmark_layouts.py --datasets 1x 10x --base-mib 2 --rounds 1`. This scales down both datasets and verifies the result locally. Supply `--public /path/to/sg13g2_io.gds` to reuse a copy of the public input. Use the full sizes when comparing throughput or peak memory.
## Window clipping on one dense layer
A separate layouttk 0.2.0 experiment used KLayout to write a single-cell OASIS file containing 100,000 and 1,000,000 rectangles on layer 7/0. Rectangle number `i` spans `(20i, 0)` to `(20i + 10, 10)` on a 1 nm grid. Both inputs were clipped to `0,0,5,10`. KLayout independently found a single output rectangle and empty XOR with the reference clip.
| Rectangle count | OASIS bytes | Two-pass elapsed time | Peak process RSS |
| ---: | ---: | ---: | ---: |
| 100,000 | 148,495 | 0.02 s | 3.80 MiB |
| 1,000,000 | 1,467,607 | 0.21 s | 4.38 MiB |
These are single measurements on an Apple M4 with the release CLI. Run `layouttk --oas-budget-bytes 4096 clip source.oas output.oas --top TOP --layer 7/0 --window=0,0,5,10` on the two fixtures. The OASIS budget covers retained decoder data. RSS also includes decoder buffers, the process and the output. The experiment uses fixed small output from a flat synthetic source. For datasets with dense window overlap or large compact arrays, measure those workloads separately.