-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another noisy PR 🫠 Adds an `extension_ref: Weak<Extension>` field on `CustomType`, pointing to the defining extension. This is a continuation of #1719, and should be the last step before #1613. The main problem with adding the field is that types can no longer be `const`-initialized. That means that every definition for, for example, `const QB_T: Type` now has been changed to a runtime function. This mean that we can no longer use the static `type_row!` constructor when using custom types, and must resort to a `vec!` (and many `into()`s...). I think with this the `Cow` inside a type row is not that useful anymore, and it may be better to just drop it in favour of vecs, perhaps with internal `Arc`s (I'll open an issue about this). Benchmark comparison after this change (showing those with >5% change): ``` group base custom-type-refs ----- ---- ---------------- builder/simple_cfg 1.00 15.1±0.22µs ? ?/sec 1.25 18.9±0.19µs ? ?/sec builder/simple_dfg 1.00 1534.3±50.82ns ? ?/sec 1.76 2.7±0.04µs ? ?/sec circuit_roundtrip/json/0 1.00 8.1±0.12µs ? ?/sec 1.06 8.6±0.16µs ? ?/sec circuit_serialize/json/0 1.00 1627.5±24.52ns ? ?/sec 1.34 2.2±0.04µs ? ?/sec circuit_serialize/json/1 1.00 6.5±0.17µs ? ?/sec 1.10 7.2±0.09µs ? ?/sec singleton_subgraph/10 1.15 231.9±84.31ns ? ?/sec 1.00 201.3±4.53ns ? ?/sec ``` There's a slight increase in building time for small circuits, but most tests are unchanged / tend to 1.00 for larger sizes. --- Review help. This is a list of the interesting bits of this PR, lost inside the noise. - The trait `MakeOpDef` in `prelude/simple_op.rs` now has two new methods `extension_ref` and `init_signature`, so we can pass the `Weak<Extension>` around while the extension is being initialized and avoid deadlocks due to calling e.g. the `PRELUDE` lazy_static recursively. This caused all the simple op definitions to be updated with those defs. - `BOOL_T`, `QB_T`, `USIZE_T` are now (lowercase) methods. This is the main source of noise since it modifies a lot of tests. - `CustomType` in `types/custom.rs` has a new `extension_ref` field. - Running this revealed that one of the `hugr-model` roundtrip tests defined the `Array` type as coming from an inexistent `array` extension. I replaced it with `prelude`. --- drive-by: Make `just format` format non-default targets BREAKING CHANGE: Removed `CustomType::new_simple`. Custom types can no longer be const-constructed. BREAKING CHANGE: Added `init_signature` and `extension_ref` methods to the `MakeOpDef` trait. BREAKING CHANGE: Redefined the `const` types in the prelude to generator functions. --------- Co-authored-by: Mark Koch <[email protected]>
- Loading branch information
Showing
77 changed files
with
1,125 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.