Ideas to improve performance for dbachecks with Pester v5 compared to v4? Getting a single Tag from a file with 100 +Tags #2331
-
Terminology - a We are currently rewriting dbachecks to use Pester v5 (using this project in case anyone fancies helping out! ) So that we can ensure that when we rewrite we are testing the same, passing for the same and failing for the same because these are databases we are talking about and we are (ex) DBAs and cautious folk, @jpomfret and I wrote a dev container configuration with 3 sql instances and also a function that is loaded into the session that will run the same check against the 3 instances in the dev container and compare the output to see if they are the same. (This has caught some coding misconceptions :-) ) We also use Sampler to build and deploy the module so that we are developing in clean sessions ( if you want to follow along instructions are here) We also want to improve the performance of the checks as we had scenarios where you could run 5 different checks against the same instance and actually return to the instance 5 times to get the same information !! So we added to the above function to use Jakubs profier module to work out what is happening. Now we want to gather the information from a single trip to the instance so we identify the unique checks that we are running, work out which files they are in and add that to the So that is the background. Now the issue. If we look at a number of checks like this
then it runs for a minute and outputs We are amazing, running the same tests against the same instances on the same hardware gives the same results and runs in 50% of the time with our new code. AWESOME. However, and the reason for this question. If we change that to run only a single check
We get Yes with different single checks, yes the hardware is the same, we are in a dev container, the test run straight after each other, it doesnt matter the host that you use, you can even get the same resutls in the codespace. So we can look at the perf detail. We normally use this to try and improve our code. Running a single check takes between 150% and 300% longer
So we have something using 40+% of our duration, lets find out what
$traci.Top50SelfDuration[0] |fl
So it appears that it is this code that is causing the slowup, which I don't claim to understand the reasoning for.
The question is - how do we fix this? Answers on a post card please. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
@SQLDBAWithABeard that code is cleaning up orphaned mock hook functions that might be in place when you cancel a run. In non-interactive session this code should be rarely needed (so maybe we can skip it). It runs once per run (once per Invoke-Pester), how many times are you calling Invoke-Pester? It shows 38 hits above. The time impact is probably constant ~5s for both multiple filters and single filter. |
Beta Was this translation helpful? Give feedback.
-
Could you also run |
Beta Was this translation helpful? Give feedback.
-
and then I find another one !! - #2335 |
Beta Was this translation helpful? Give feedback.
@SQLDBAWithABeard that code is cleaning up orphaned mock hook functions that might be in place when you cancel a run. In non-interactive session this code should be rarely needed (so maybe we can skip it). It runs once per run (once per Invoke-Pester), how many times are you calling Invoke-Pester? It shows 38 hits above. The time impact is probably constant ~5s for both multiple filters and single filter.