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

Fix compression speed gains #616

Merged
merged 3 commits into from
Oct 29, 2024
Merged

Fix compression speed gains #616

merged 3 commits into from
Oct 29, 2024

Conversation

petrprikryl
Copy link
Contributor

@petrprikryl petrprikryl changed the title fix compress speed - generators cannot yield from in threads? fix compress speed - generators cannot yield from threads? Oct 29, 2024
@adamchainz
Copy link
Collaborator

Thank you for investigating and fixing. I definitely overstepped in my refactoring there 😅

@adamchainz adamchainz changed the title fix compress speed - generators cannot yield from threads? Fix compression speed gains Oct 29, 2024
@adamchainz
Copy link
Collaborator

Okay, I figured what went wrong. In my testing, I used python -m whitenoise.compress locally, because it's easier to just run the in-dev version like that. Now I used uv pip install -e .../whitenoise and ./manage.py collectstatic, and can verify your changes give my test project a 5x boost.

I fixed the other _compress_path() method in whitenoise.storage. I also eliminated the use of a generator in Compressor.compress(), which may lead to an extra speed boost.

@adamchainz adamchainz merged commit 61853c7 into evansd:main Oct 29, 2024
13 checks passed
github-actions bot added a commit to xshapira/fastapi-django-template that referenced this pull request Oct 30, 2024
Bumps [whitenoise](https://github.com/evansd/whitenoise) from 6.8.1 to
6.8.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/evansd/whitenoise/blob/main/docs/changelog.rst">whitenoise's
changelog</a>.</em></p>
<blockquote>
<h2>6.8.2 (2024-10-29)</h2>
<ul>
<li>
<p>Fix compression speed gains for the thread pool when running Django’s
<code>collectstatic</code>.
The thread pool had no effect due to use of a generator for the results,
a refactoring introduced when reviewing the initial PR.</p>
<p>Thanks to Petr Přikryl for the investigation and fix in <code>PR
[#616](evansd/whitenoise#616)
&lt;https://github.com/evansd/whitenoise/pull/616&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/evansd/whitenoise/commit/2f75ac85f322fe368bfdb2d21d0fd672b7b96f06"><code>2f75ac8</code></a>
Version 6.8.2</li>
<li><a
href="https://github.com/evansd/whitenoise/commit/61853c74ed2790a99474b6e4e2a8f1efc762dd3b"><code>61853c7</code></a>
Fix compression speed gains (<a
href="https://github.com/evansd/whitenoise/issues/616">#616</a>)</li>
<li>See full diff in <a
href="https://github.com/evansd/whitenoise/compare/6.8.1...6.8.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=whitenoise&package-manager=pip&previous-version=6.8.1&new-version=6.8.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
mkjpryor pushed a commit to azimuth-cloud/azimuth that referenced this pull request Nov 1, 2024
Bumps [whitenoise](https://github.com/evansd/whitenoise) from 6.8.1 to
6.8.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/evansd/whitenoise/blob/main/docs/changelog.rst">whitenoise's
changelog</a>.</em></p>
<blockquote>
<h2>6.8.2 (2024-10-29)</h2>
<ul>
<li>
<p>Fix compression speed gains for the thread pool when running Django’s
<code>collectstatic</code>.
The thread pool had no effect due to use of a generator for the results,
a refactoring introduced when reviewing the initial PR.</p>
<p>Thanks to Petr Přikryl for the investigation and fix in <code>PR
[#616](evansd/whitenoise#616)
&lt;https://github.com/evansd/whitenoise/pull/616&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/evansd/whitenoise/commit/2f75ac85f322fe368bfdb2d21d0fd672b7b96f06"><code>2f75ac8</code></a>
Version 6.8.2</li>
<li><a
href="https://github.com/evansd/whitenoise/commit/61853c74ed2790a99474b6e4e2a8f1efc762dd3b"><code>61853c7</code></a>
Fix compression speed gains (<a
href="https://github.com/evansd/whitenoise/issues/616">#616</a>)</li>
<li>See full diff in <a
href="https://github.com/evansd/whitenoise/compare/6.8.1...6.8.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=whitenoise&package-manager=pip&previous-version=6.8.1&new-version=6.8.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

2 participants