Skip to content

Performance degradation in google-api-core #16552

@Crowiant

Description

@Crowiant

Determine this is the right repository

  • I determined this is the correct repository in which to report this bug.

Summary of the issue

Context
Upgrading google-api-core from version 2.27.0 to 2.28.1 (and later) has caused a significant spike in CPU usage. While version 2.27.0 maintains a steady 20–40% utilization, versions 2.28.1 and above consistently reach 100% CPU consumption.

Expected Behavior:
Same consumption of CPU as in 2.27.0

Actual Behavior:
CPU consumption increased up to 5 times.

API client name and version

google-api-core v. 2.28.1 - 2.30.0

Reproduction steps: code

file: main.py

import time
import importlib
import google.api_core

time.sleep(5)

def test_api_core():
    importlib.reload(google.api_core)


for _ in range(2000):
    test_api_core()

print("Successfully imported 2000 times.")

Reproduction steps: supporting files

file: Dockerfile

FROM python:3

WORKDIR /app

RUN pip install --no-cache-dir google-api-core==2.28.1 grpcio

COPY main.py .

CMD ["python", "main.py"]

Reproduction steps: actual results

docker stats:
2.30.0

Image

2.27.0

Image

Reproduction steps: expected results

OS & version + platform

No response

Python environment

No response

Python dependencies

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions