Skip to content

Extremely long request time with StaticFilesPanel #1394

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
pembo13 opened this issue Oct 21, 2020 · 4 comments
Open

Extremely long request time with StaticFilesPanel #1394

pembo13 opened this issue Oct 21, 2020 · 4 comments

Comments

@pembo13
Copy link

pembo13 commented Oct 21, 2020

I just recently upgraded from django-debug-toolbar==2.2 to django-debug-toolbar==3.1.1. Unfortunately, I did this after a few changes to the core behaviour of the project in question, and so upon noticing a significant increase in response times, across all views I started taking apart changes to no available until I downgraded django-debug-toolbar and everything went back to normal.

Coming here, If found #1263, and proceeded to start testing the removal of panels, starting with an empty DEBUG_TOOLBAR_PANELS. Ultimately, I singled out debug_toolbar.panels.staticfiles.StaticFilesPanel

To quantify the problem, using response times as seen in Firefox's Network Tab for a HTML response:

  • with 2.2: ~0.030 s
  • with 3.3.1 (no settings.py changes): ~1.100 s
  • with 3.3.1 (declaring DEBUG_TOOLBAR_PANELS and commending out StaticFilesPanel: ~0.030 s
@matthiask
Copy link
Member

Do you have additional details where the slowdown happens?

@pembo13
Copy link
Author

pembo13 commented Dec 9, 2024

@matthiask I believe the source of of the slowdown is is get_staticfiles_finders(), accounting for over over 99% of the time of generate_stats():

num_found 0.00000
num_used 0.00005
staticfiles 0.00002
staticfiles_apps 0.00384
staticfiles_dirs 0.00005
staticfiles_finders 1.65044

It's enumerating every static file, used or not, in order to display "django.contrib.staticfiles.finders.FileSystemFinder (95449 files)" and list all these files in the result panel. I'm not sure how useful that is, but it's time consumption is likely proportional to the number of files.

@matthiask
Copy link
Member

Thanks! Yeah, that sounds right. Also, it will possibly be much worse if people are using a cloud-based static files storage.

I'm not sure enumerating all available static files is all that useful.

@pembo13
Copy link
Author

pembo13 commented Dec 11, 2024

@matthiask maybe if just disabling static file enumeration via configuration would solve the issue.

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

No branches or pull requests

2 participants