Remove the quadratic bookkeeping that dominated parsing large hierarc… - #648
Merged
Conversation
…hical netlists Two linear scans in the netlist core turned the Verilog parser quadratic on hierarchical netlists (OpenTitan Earl Grey: 25,906 modules, 1.86 million nets created and 460k merged away, 2.3 million endpoints): - Deleting a gate, net, or module removed it from the netlist's (and the module's) object vector with a linear std::find. The vectors now keep the position of every element in a map, and removal is a swap with the last element in constant time (utils::indexed_vector_push_back / erase). - Module::is_parent_module_of walked this module's whole subtree; for the top-level modules that is the entire hierarchy, once per endpoint whenever module nets are recomputed. It now walks up the parent chain of the queried module, bounded by the hierarchy depth. Module::set_parent_module detaches the module and updates its parent before the old parent re-checks its nets, which the upward walk requires. Release parse of the 216 MB Earl Grey netlist: 709 s -> 31 s. All netlist, module, net, gate, and grouping tests pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
julianspeith
enabled auto-merge (squash)
September 10, 2026 09:42
julianspeith
disabled auto-merge
September 10, 2026 09:42
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…hical netlists
Two linear scans in the netlist core turned the Verilog parser quadratic on hierarchical netlists (OpenTitan Earl Grey: 25,906 modules, 1.86 million nets created and 460k merged away, 2.3 million endpoints):
Deleting a gate, net, or module removed it from the netlist's (and the module's) object vector with a linear std::find. The vectors now keep the position of every element in a map, and removal is a swap with the last element in constant time (utils::indexed_vector_push_back / erase).
Module::is_parent_module_of walked this module's whole subtree; for the top-level modules that is the entire hierarchy, once per endpoint whenever module nets are recomputed. It now walks up the parent chain of the queried module, bounded by the hierarchy depth. Module::set_parent_module detaches the module and updates its parent before the old parent re-checks its nets, which the upward walk requires.
Release parse of the 216 MB Earl Grey netlist: 709 s -> 31 s. All netlist, module, net, gate, and grouping tests pass.