Repository navigation
CPU Saturation test (prerequisite for #1175 PR) - #1187
janko-petkovic wants to merge 7 commits into
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1187 +/- ##
==========================================
- Coverage 84.55% 75.61% -8.95%
==========================================
Files 96 96
Lines 7603 7603
==========================================
- Hits 6429 5749 -680
- Misses 1174 1854 +680
Flags with carried forward coverage won't be shown. Click here to find out more. |
janfb
left a comment
There was a problem hiding this comment.
Great, thanks for starting this!
I added a couple of comments and question. We can also discuss in person if that's more efficient.
| for th in theta: | ||
| # time.sleep(0.05) | ||
| x.append(diagonal_linear_gaussian(th.reshape(1, -1))) |
There was a problem hiding this comment.
is the commented out sleep a left over?
Also, is the for-loop on purpose to make it slow?
There was a problem hiding this comment.
The commented out sleep is a left over yes.
The for loop I left in there in case the test wanted to be run with a batched simulation.
| # toc_joblib = time.time() - tic | ||
|
|
||
| # Allow joblib to be 50 percent slower due to overhead. | ||
| # assert toc_joblib <= toc_sp * 1.5 |
There was a problem hiding this comment.
why is this commented out?
If we know this fails (and will be fixed in the future), we could use an pytest.mark.xfail above.
There was a problem hiding this comment.
You are correct, I didn't think about that.
There was a problem hiding this comment.
this is essentially the same test as above, no?
I am not sure what the purpose of the above test is then, but probably I am missing something.
Maybe, the new test above is just a temporary thing to see the saturation locally in htop?
There was a problem hiding this comment.
This is the old test that was already in the sbi library. The only thing I did here is to swap simulate_in_batches with simulate_for_sbi, since the former will not be used after the refactoring.
This test (multiprocessing_test) has the same purpose as before, checking that multiprocessing and batching actually work better than serial computation.
On the other hand, as you correctly noticed, cpu_saturation_test.py is meant just to verify that the joblib PR indeed made things better. In my opinion it can be safely removed afterwards.
|
I suggest, one the other PR #1188 is merged, we can merge |
Sure makes sense and keeps main history less cluttered. I'd then post the runtime differences in this thread. |
|
Here are the performances before and after the Interestingly, the CPU usage is not fully saturated in either case: This could be due to the fact that the test is not computationally intensive, as other, heavier, simulations have shown to fully saturate CPU with the new implementation. At this point, this branch has served its proof-of-concept purpose and can be deleted without merging (to the best of my understanding). |




This branch includes an additional test aimed at highlighting the CPU usage while running a high number of simulations.
...
Does this close any currently open issues?
This is an addition that aims to give the devs a way to test the fix that will be proposed in the next days for the
simulate_for_sbifunctionAny relevant code examples, logs, error output, etc?
You don't need to let the test finish, it is just supposed to provide the workload.
Any other comments?
Remember that the testing is actually done by looking at the process manager / htop while the test is running.
Checklist
Put an
xin the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.
guidelines
with
pytest.mark.slow.guidelines
main(or there are no conflicts withmain)