WordPress / WordPress/Requests

Performance issue with Requests.php decompress() / compatible_gzinflate() functions

Open
#153 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
500
Avg merge
2d 21h
Merged PRs (30d)
5

Description

Currently the function: decompress() speculatively attempts the following in turn:

  1. gzdecode(...)
  2. gzinflate(...)
  3. self::compatible_gzinflate(...)
  4. gzuncompress(...)

However, #3 compatible_gzinflate(...) includes within it (at Lines 834 to 838) a "fallback" call to gzinflate(...) which is identical to that attempted at #2.

Hence if #2 fails. it may be uselessly repeated within #3.

One solution may be to do BOTH the following:

  • MOVE the "fallback" in compatible_gzinflate(...) to the beginning of that function (i.e. make it the first inflation attempted), and
  • REMOVE from decompress() function the gzinflate(...) attempt at #2.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Requests.php by reading decompress() and compatible_gzinflate(), especially the fallback around lines 834–838. Confirm how the repeated gzinflate() attempt is reached, then make the call-order change without altering the other decompression fallbacks and verify the existing test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
networking
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.