question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding the whitenoise middleware can greatly slow down your tests. If you have processes static previously and your static directory is full of static files. Then the middleware, on each test method, process the list of files over and over. So your tests are now slowed by a function of how many static files you have.

On startup this is called:

    def update_files_dictionary(self, root, prefix):
        for directory, _, filenames in os.walk(root, followlinks=True):
            for filename in filenames:
                path = os.path.join(directory, filename)
                url = prefix + os.path.relpath(path, root).replace('\\', '/')
                self.files[url] = self.get_static_file(path, url)

And if you have thousands of static files, this will slow it down.

Perhaps this list could be lazy loaded on first call rather than init.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
edmorleycommented, May 2, 2017

Also perhaps mentioning in the documentation that it’s recommended to disabling file scanning during tests?

0reactions
cjerdonekcommented, Feb 26, 2018

I’m new to whitenoise and just saw this issue after running into it.

@evansd’s idea to store the result of walking the directory in a file occurred to me, too, and I think makes a lot of sense:

It ought to be possible to cache the entirety of WhiteNoise’s state by pickling the self.files attribute to a file somewhere,

It seems like this would be an especially good fit e.g. for people using Docker. The file could be generated as part of the Docker build and stored in the Docker image itself (or maybe generated on container startup).

I’m not sure if there’s already an open issue for this feature, but it does relate to the general issue #141 (“Make whitenoise faster”), which is still open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5-Step Strategy for Optimizing Slow Tests - Semaphore CI
Slow tests affect development. Engineering teams lose momentum and become frustrated because they can't meet their goals. A slow test suite ...
Read more >
the chainsmokers - testing (slowed) - YouTube
the chainsmokers - testing (slowed). 2.2K views 7 months ago. aiden's aesthetics.
Read more >
Fast fixes for slow tests: How to unclog your CI pipeline
It's common that slow tests are overloaded—they try to do too many things. By paring down the steps each test has to perform,...
Read more >
Slow Tests | DevLead.io
Here are some solutions to these common causes for slow tests: High Latency. You will often experience high latency when the System Under ......
Read more >
Debugging Why Your Specs Have Slowed Down - Thoughtbot
Your test suite used to be lightning fast but now it's starting to feel a bit sluggish. Before adding CI parallelization, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found