High CPU usage if request content is bytes

Open
#737 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python

Research direction

Reproduce the report by comparing a 10MB bytes request body with the equivalent io.BytesIO content on the affected HTTP client. Trace request-content handling to identify why the bytes form causes sustained CPU usage, then verify that both forms send the same data without the reported CPU spike.

Written by the indexing model from the issue text.

Description

Originally opened by @kice on 2023-01-26 08:56:35 in encode/httpx

I noticed a increase of CPU usage after I changed request content from content=io.BytesIO(b'<actual data>') to content=b'<actual data>'. The content I want to send is 10MB in size, which is not that much, but still considerable amount of data.

My code is running on a VPS with low end CPU, which makes it much more dramatic (from peek at 40% to pinned at 100%).

I would like to help debug this issue, but I need some instructions to do so.

Dominant language
Python
Stars
1.6k
Forks
103
Avg merge
1d 19h
Merged PRs (30d)
25

Getting set up

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.

More from pydantic/httpx2

All issues in pydantic/httpx2

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.