Skip to content

[8.18.1] warn_stacklevel is slowing down the client #3003

@folkvir

Description

@folkvir

Hello!

We noticed in the 8.18.1 client that the function warn_stacklevel called when a warning is emitted that the function used to fetch the stack is slowing down our service with at least a factor 2. As an example, for a normal 45/55 minutes run of tests with the client 7 we now waits for almost 2 hours with the client 8 for the same workload and same number of tests.

Compared to the client v7 where the stacklevel was 2, here you dynamically fetch the stacklevel by parsing the stack through inspect.stack() which can be very very slow.

Here an example of calling 2 times get_alias with the client v8 instrumented by pyinstrument.

Image

As you can see the warn_stacklevel is very time consuming compared to the request itself.

As a temporary patch we fixed this value to 0 but this is not a long-term solution so if you could provide a better alternative it will be very appreciated!

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