Bug 2022889 - Add MWU result caching to performance api - #9753
Conversation
✅ Deploy Preview for treeherder ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1f80d1b to
0b6b414
Compare
|
|
||
|
|
||
| class PerfCompareMwuCache(models.Model): | ||
| hash_key = models.CharField(max_length=64, unique=True, db_index=True) |
There was a problem hiding this comment.
Added index since I'm not sure how big this table will grow. (Ticket mentions adding a job to delete old entries but also mentions we might keep these around)
|
|
||
| if test_version == "mann-whitney-u": | ||
| json_safe_data = json.loads(json.dumps(serialized_data, cls=DecimalEncoder)) | ||
| PerfCompareMwuCache.objects.create(hash_key=cache_key, results=json_safe_data) |
There was a problem hiding this comment.
get_or_create is safer in case two requests race for the same key
| first_response = client.get(reverse("perfcompare-results") + query_params) | ||
| assert first_response.status_code == 200 | ||
| assert PerfCompareMwuCache.objects.count() == 1 | ||
| _first_cache_key = PerfCompareMwuCache.objects.first().hash_key |
There was a problem hiding this comment.
_first_cache_key is assigned but never read
| @@ -1292,6 +1296,27 @@ def list(self, request): | |||
|
|
|||
| # Process results based on test version | |||
| if test_version == "mann-whitney-u": | |||
There was a problem hiding this comment.
nit: Initialize cache_key to None before the if block:
| if test_version == "mann-whitney-u": | |
| cache_key = None | |
| if test_version == "mann-whitney-u": |
| extra_options = "e10s fission stylo webrender" | ||
| measurement_unit = "ms" | ||
|
|
||
| base_sig = create_signature( |
There was a problem hiding this comment.
All three new tests repeat the same ~50-line block of setup: creating base_sig, new_sig, populating PerformanceDatum rows.
nit: To reduce duplication, we could move this setup logic into a common helper or a pytest fixture.
Add caching of results to backend of perfcompare API