django-debug-toolbar icon indicating copy to clipboard operation
django-debug-toolbar copied to clipboard

Cache panel causes very slow page loads

Open jgillard opened this issue 3 years ago • 1 comments

The cache panel is causing a very large slowdown in page loads when it is enabled.

I've just tested an admin list page, and without the cache panel enabled it loads in ~750ms, but with it enabled it takes 25 - 30 seconds (I averaged 3 page loads of each for these numbers). The cache panel shows that there are 12 total calls on this page, and times them at ~1.4ms.

I feel like this behaviour is relatively recent, so I tried dropping our version of Django which we upgraded recently. On Django 3.2.11, the page load time with the panel disabled is the same, but with it enabled the times are lower at 13 - 18s. Django pre-4.0 is faster, but still much slower than I think would be expected.

Trying on a non-admin page, I found the page loads times to be low for both Django versions with the panel disabled, and around 10x higher for both with it enabled.

For all these tests, the load times were not very reproducible when flicking between versions and restarting Django, so I've only included a few of them here. What I did notice across all of this testing is that with the panel enabled, load times often increase on each reload e.g. first load takes 2s, then 2.5s, then 3s...

This test was run on MacOS, and I've had a colleague confirm my observations on Linux also.

I'm happy to do some debugging if pointed in the right direction.

Versions: Python 3.9.9 Django 4.0.1 django-debug-toolbar 3.2.4

jgillard avatar Jan 20 '22 11:01 jgillard

@jgillard can you create a reproducible environment that we could verify this with? If needed, you fork the repo and use the example app as a starting point. Though it may be easier to share the models and admin classes with the caching logic.

tim-schilling avatar Jan 20 '22 14:01 tim-schilling

@jgillard what were you using for caching? And do you have the example of how to use the caching that causes this?

tim-schilling avatar Aug 29 '22 00:08 tim-schilling

I’ll try to retest this soon, apologies for not managing to follow up so far. I’ve seen the cache panel mentioned in recent releases so my hope is that I won’t be able to replicate what I saw previously.

Thanks for all the hard work on this extension btw. Performance improvements to the SQL panel recently have been very happily received, it’s made a big difference for me.

jgillard avatar Sep 07 '22 22:09 jgillard

I've retested a selection of admin and non-admin pages and cannot replicate this, so I think this must have been solved by changes to the cache panel since my original post. Feel free to close.

For reference the versions I've just tested with are: Python 3.10.6 Django 4.0.7 django-debug-toolbar 3.6.0

jgillard avatar Sep 09 '22 16:09 jgillard