Commit 41263ba
Fixes #1696
# Description
This PR implements some of the key insights @Huite found while optimzing
the splitting of Models. Although there are some differences in his
implementation and this PR. The optimizatiob exists of 2 parts
The First part has to do with the way models and packages are split. As
@Huite pointed out the current implementation leads to a package being
loaded and unloaded several times, which leads to a huge performance
penalty because the package needs to be loaded from disk each time.
This has been solved by reverting the order of looping. In the original
implementation there was a loop over the models, foreach partition a
deepcopy was made of the original model. Then afterwards we loop over
each model and access each package in the model to determine if it
belongs to the same domain as the model. This is expensive.
This PR reverts the loop. Frist a shallow copy is made of all the
models. Then we loop over each package of the original package and we
determine if belongs to once of the submodels. This way we only need the
open a package once.
The second part is the way the SSM and BUY packages are updated after
the splitting has happend. There was a pience of code that looped over
all the flow and transport models to determine which models share the
same domain (are in the same partition). This is an expensive operation
because the grid data has to be loaded into memory over and over.
In this PR this has been solved by bringing the update of the SSM and
BUY package to the place where that information is already know i.e. the
model splitter. This way we can avoid the expensive loading of the grid
data.
Also by moving it to the modelsplitter we can avoid forcing the load of
the grid data manually
With these changes the splitting of the mode @Huite provided me takes
now around 5m:30s
# Checklist
<!---
Before requesting review, please go through this checklist:
-->
- [x] Links to correct issue
- [ ] Update changelog, if changes affect users
- [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737``
- [ ] Unit tests were added
- [ ] **If feature added**: Added/extended example
- [ ] **If feature added**: Added feature to API documentation
- [ ] **If pixi.lock was changed**: Ran `pixi run generate-sbom` and
committed changes
---------
Co-authored-by: JoerivanEngelen <joerivanengelen@hotmail.com>
1 parent b0dc733 commit 41263ba
File tree
18 files changed
+452
-141
lines changed- docs/api
- imod
- common/interfaces
- mf6
- multimodel
- msw
- tests/test_mf6
- test_multimodel
- typing
18 files changed
+452
-141
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
716 | | - | |
| 716 | + | |
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
737 | | - | |
| 737 | + | |
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
| 746 | + | |
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| |||
0 commit comments