Improve performance for large models with DomainViewDict#138
Conversation
|
Just added a commit which shaves off about ~7 sec of initialization time for the E-lite model |
|
...and just made another commit that shaved another 7 sec off initialization. Generating the default |
|
Good idea to de-couple those from the |
|
@pshriwise The global dictionaries are accessed from the |
Understood, but any reason not to make the |
|
Ok, I was able to come up with a better (I think?) solution here. Instead of storing the defaults as a global dictionary, they are stored as an attribute on |
pshriwise
left a comment
There was a problem hiding this comment.
Just one small question about a change to the default pixel size, but then I think this is ready! 🚀
Thanks for this update! I tried out the E-lite model out (both before and after these changes) and it makes a big difference -- bring on the detail!
| self.height = height | ||
| self.h_res = 1000 | ||
| self.v_res = 1000 | ||
| self.h_res = 100 |
There was a problem hiding this comment.
Do we want to change the default pixel values permanently? I think for most models this default is manageable.
There was a problem hiding this comment.
Come to think of it, being able to set the initial number of pixels might be a nice option to have -- making an issue...
There was a problem hiding this comment.
That was unintentional, got a little overzealous with git commit -a 😊 But yes! we absolutely should have an option to change the default resolution
There was a problem hiding this comment.
Ah, right one. Issue #139 created so we can tackle that later. Thanks!!
pshriwise
left a comment
There was a problem hiding this comment.
Thanks for the performance upgrade @paulromano!

If you run the plotter on a model with lots of cells (the ITER E-lite model, for example), it spends a lot of time copying data around unnecessarily. The crux of the issue is this line:
plotter/openmc_plotter/plotmodel.py
Line 321 in e772fb9
which deepcopies the entire
PlotViewobject. This object holds dictionaries calledcellsandmaterialsthat map cell and material IDs toDomainViewobjects (one for each cell and material that appears in the model). When I plot the ITER E-lite model, which has >300k cells, those deepcopies take about 12 seconds on my machine, which means that every time I update the plot view, there is a lag of 12 seconds even when the plot resolution is super low.This PR makes a fairly easy fix to this problem, which is to store a global dictionary that holds the default
DomainViewview settings that are created at startup separately from thePlotViewobject itself. If you make a modification to the domain view (e.g., changing the color of a material), it does get stored as part thePlotViewobject and will get copied around, but the default domain views remain untouched and don't get copied.