Skip to content
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

Added a distribution tab to visualize request time distributions over time #281

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

danielbradburn
Copy link
Contributor

@danielbradburn danielbradburn commented May 4, 2018

This PR adds a distribution tab (at the moment opt in using the SILK_DISTRIBUTION_TAB configuration setting) with a visualisation of the request time distributions grouped by date or revision. We are using this at crunchr for continous benchmarking to ensure we don't introduce changes to our codebase that degrade the performance of our backend. This might be particularly useful for benchmarking django apps over time or versions.

11

@avelis avelis requested a review from albertyw May 4, 2018 21:03
Copy link
Member

@albertyw albertyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'm not sure if dealer is the best package to use here. It's not very popular and there are more tested and up-to-date python libraries to introspect version control information. A lot of django production deployments also won't contain git repository data.
  • Tests currently don't pass and should be fixed.

requirements.txt Outdated
@@ -11,3 +11,4 @@ Django>=1.11
freezegun>=0.3
factory-boy>=2.8.1
gprof2dot>=2016.10.13,<2017.09.19
dealer>=2.0.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking out dealer, it seems dealer may be out of date. Have you tried testing with django >= 1.10 (klen/dealer#24)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look for an alternative to dealer. I think the revision fuctionality is not that useful in production, at least we don't use it, we set SILKY_REVISION to a version number in settings.py. But it is quite useful for benchmarking locally, for example for comparing a number of commits. If I can't find a better alternative I guess another option is to just remove this dependency and let users set to the revision number using whichever method they prefer (probably nice to have an example in the readme)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check out the failing tests.

@@ -0,0 +1,102 @@
try:
# Django>=1.8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of fa1f542, django-silk does not support django<1.11

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good, improves this code!

@@ -0,0 +1,199 @@
(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an unminified copy of url.min.js? Do we need both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no, I will remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertyw I removed this unnecessary file

@@ -94,13 +94,13 @@ <h4>Profile</h4>
value="OverallTimeFilter"
name="filter-overalltime-typ"/>
<input type="text"
placeholder="seconds"
placeholder="milliseconds"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bugfix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a typo fix, since the placeholder says 'seconds' but the filter actually accepts 'milliseconds', do you think it makes sense to make a separate PR for this?

silk/config.py Outdated
timestamp = auto._repo.git('show -s --format=%at ' + revision)
revision = ' # '.join([timestamp.decode(), revision])
except:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make more sense to be revision = ''?

And does the rest of the app work correctly with an empty string or None value? There seem to be several areas of the app that filter or group by revision value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertyw I removed the dealer dependency now - I think it's simpler just to let users to set the revision themselves using whichever method they prefer. This is what we have ended up doing when running this branch in production.

@albertyw albertyw requested a review from avelis May 6, 2018 07:04
@moagstar
Copy link
Contributor

@albertyw @avelis Apologies for letting this PR sit for so long. I have fixed the tests, and am curious if there is any further feedback or if this can be merged. Let me know if you have any questions.

@nasirhjafri nasirhjafri self-requested a review October 17, 2020 15:25
@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #281 (ee6d6cb) into master (30eccfe) will decrease coverage by 52.03%.
The diff coverage is 25.24%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #281       +/-   ##
===========================================
- Coverage   82.83%   30.80%   -52.04%     
===========================================
  Files          50       52        +2     
  Lines        2051     2136       +85     
===========================================
- Hits         1699      658     -1041     
- Misses        352     1478     +1126     
Impacted Files Coverage Δ
silk/config.py 80.95% <ø> (-9.53%) ⬇️
silk/templatetags/silk_inclusion.py 0.00% <0.00%> (-96.56%) ⬇️
silk/urls.py 0.00% <0.00%> (-100.00%) ⬇️
silk/views/clear_db.py 0.00% <0.00%> (-96.00%) ⬇️
silk/views/distribution.py 0.00% <0.00%> (ø)
silk/views/requests.py 44.04% <16.66%> (-48.73%) ⬇️
silk/request_filters.py 37.93% <21.05%> (-27.48%) ⬇️
silk/views/profiling.py 27.08% <50.00%> (-60.42%) ⬇️
silk/views/summary.py 37.09% <50.00%> (-54.84%) ⬇️
silk/models.py 51.79% <59.09%> (-35.11%) ⬇️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30eccfe...ee6d6cb. Read the comment docs.

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this migrations and regen again with django 2.2+ only.

def filters_from_request(request):
class RevisionFilter(BaseFilter):
def __init__(self, value):
super(RevisionFilter, self).__init__(value, revision=value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of expliclit RevisionFilter, self) in super()

</div>


</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no newline

@@ -89,4 +91,19 @@
view=CProfileView.as_view(),
name='cprofile',
),
url(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using path() would be better choice as url() is deprected

@@ -0,0 +1,53 @@
import csv
import contextlib
from six import StringIO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

six is not needed

@Archmonger
Copy link
Contributor

@moagstar do you have time to address @auvipy 's change requests?

@moagstar
Copy link
Contributor

@moagstar do you have time to address @auvipy 's change requests?

I am no longer working at crunchr, so I don't think have permissions to push to this branch any longer (in fact I made this PR with my crunchr account). I would probably have to create a new PR from my own fork. I am not sure when I would have time to look at this though, since we don't use silk at my new job and personal time for programming is quite limited at the moment.

@auvipy
Copy link
Contributor

auvipy commented Sep 28, 2021

@moagstar do you have time to address @auvipy 's change requests?

I am no longer working at crunchr, so I don't think have permissions to push to this branch any longer (in fact I made this PR with my crunchr account). I would probably have to create a new PR from my own fork. I am not sure when I would have time to look at this though, since we don't use silk at my new job and personal time for programming is quite limited at the moment.

thanks for your work, i might end up opening a cleaner version of your work

@auvipy auvipy self-assigned this Nov 12, 2021
@eduzen
Copy link
Contributor

eduzen commented Feb 9, 2022

Hey @auvipy did you have time to check it? If not, I would like to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants