Skip to content

High CPU Usage (100%) in Specific Scenarios #781

Closed
@niceskylei

Description

@niceskylei

Description:

I'm experiencing an issue with the h2 crate where the CPU usage reaches 100% under specific conditions. This issue is consistently reproducible and significantly affects the performance of my application.

Steps to Reproduce:

  • Set up a tonic RPC server using the h2 crate.
  • Establish a connection from a remote client.
  • Disconnect the remote client unexpectedly (e.g., by closing the client application or terminating the network connection).
  • Observe the CPU usage on the server.

Expected Behavior:

The CPU usage should remain within normal operating limits and not spike to 100% when the remote client disconnects.

Actual Behavior:

When the remote client disconnects, the CPU usage spikes to 100% and remains there, causing severe performance degradation.

Environment:

  • h2 version: 0.3.26
  • tonic version: 0.8.2
  • Rust version: rustc 1.80.0-nightly (6e1d94708 2024-05-10)
  • Operating System: iOS 17.5

Additional Context:

use instruments analyse cpu usage
image

Log Files/Output:

using trace log level, repeatedly print below log:
queued_data_frame=false

How fix it:

image
image
I have applied a preliminary fix which seems to mitigate the issue, as the high CPU usage has not reoccurred during my initial tests. However, this fix has not been fully validated, and I am unsure if there are any other side effects or impacts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions