dan-fritchman / Hdl21

Hardware Description Library
BSD 3-Clause "New" or "Revised" License
69 stars 16 forks source link

Faster PortRef handling for Spice export #227

Open nikosavola opened 5 months ago

nikosavola commented 5 months ago

Hi,

I did some profiling on spice netlist exporting and found that most of the time at least in my case is spent in checking for PortRefs equality. I noticed that there is a SetList class that is not actually a hash map yet, this would probably help speed this up.

Image

Below is a table from running cProfile (snakeviz to be exact) and sorting by tottime ncalls tottime percall cumtime percall filename:lineno(function)
100642961 18.3 1.818E-07 22.17 2.203E-07 portref.py:37(eq)
41028 8.833 0.0002153 24.18 0.0005894 portrefs.py:307(contains)
4211 4.659 0.001106 8.701 0.002066 inspect.py:969(getmodule)
112479736/112422582 4.447 3.955E-08 4.529 4.029E-08 ~:0()
32821 3.878 0.0001182 10.7 0.0003261 portrefs.py:311(add)
10149410 1.568 1.545E-07 1.985 1.955E-07 inspect.py:283(ismodule)

Would be great to speed or avoid these calls.