-
-
Notifications
You must be signed in to change notification settings - Fork 17
Introduce a section on dealing with negative results from a t-test #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jdmarshall
wants to merge
3
commits into
RafaelGSS:main
Choose a base branch
from
jdmarshall:docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Fixing Inconclusive Tests | ||
|
|
||
| t-tests are looking at the distribution of both sets of results and trying to determine if they overlap in a way that | ||
| makes the average value significant or just noise in the results. A run with a bimodal distribution for instance, caused | ||
| by problems with the machine the tests are running on or the NodeJS runtime doing things in the background. Here are a | ||
| few causes. | ||
|
|
||
| ## Random Input Data | ||
|
|
||
| Variability in the inputs between runs can lead to big changes in the runtime of an algorithm. Particularly with code | ||
| that sorts, filters, or conditionally operates on input data, feeding them certain combinations of data will result in | ||
| wildly different run times from one loop to the next or occasionally from one sample to the next. The Central Limit | ||
| Theorem (that over a long enough time a situation will revert to the mean), does not invalidate the existence of the | ||
| Gambler's Paradox (that it will revert to the mean before I become bankrupt). | ||
|
|
||
| It is better to do your fuzzing in fuzz tests and pick representative data for your benchmarks. Partially informed by | ||
| the results of your fuzz tests, and other bug reports. | ||
|
|
||
| ## Underprovisioned VM, Oversubscribed hardware | ||
|
|
||
| For a clean micro benchmark, we generally want to be the only one using the machine at the time. There are a number of | ||
| known issues running benchmarks on machines that are thermally throttling, or on cheap VMs that use best-effort to | ||
| allocate CPU time to the running processes. In particular, docker images with `cpu-shares` are especially poor targets | ||
| for running benchmarks because the quota might expire for one timeslice in the middle of one test or between benchmarks | ||
| in a single Suite. This creates an unfair advantage for the first test, and/or lots of noise in the results. We are | ||
| currently investigating ways to detect this sort of noise, and analyzing if the t-tests are sufficient to do so. | ||
|
|
||
| ## Epicycles in GC or JIT compilation | ||
|
|
||
| If the warmup time is insufficient to get V8 to optimize the code, it may kick in during the middle of a sample, which | ||
| will introduce a bimodal distribution of answers (before, and after). There is currently not a way to adjust the warmup | ||
| time of `bench-node`, but should be added as a feature. | ||
|
|
||
| One of the nastiest performance issues to detect in garbage collected code is allocation epicycles. This happens when | ||
| early parts of a calculation create lots of temporary data but not sufficient to cross the incremental or full GC | ||
| threshold, so that the next function in a call sequence routinely gets hit with exceeding the threshold. This is | ||
| especially common in code that generates a JSON or HTML response to a series of calculations - it is the single biggest | ||
| allocation in the sequence, but it gets blamed in the performance report for the lion's share of the CPU time. | ||
|
|
||
| If you change the `minTime` up or down, that will alter the number of iterations per sample which may smooth out the | ||
| results. You can also try increasing `minSamples` to get more samples. But also take this as a suggestion that your code | ||
| may have a performance bug that is worth prioritizing. | ||
|
|
||
| Forcing GC in the teardown or setup methods between subsequent tests in a single Suite may help with some situations | ||
| when reordering the tests results in differences in runtime, but for the more general case, you may need to review the | ||
| code under test to make it 'play well' both with benchmarking and in production systems. | ||
|
|
||
| In production code, particularly where p9# values are used as a fitness test, it is sometimes better to chose the | ||
| algorithm with more consistent runtime over the one with supposedly better average runtime. This can also be true where | ||
| DDOS scenarios are possible - the attacker will always chose the worst, most assymetric request to send to your machine, | ||
| and mean response time will not matter one whit. If `bench-node` is complaining, the problem may not be `bench-node`. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call it "tests". Also, I guess this would fit better in "Writting microbenchmark" part in the README, no?