Skip to content

ContextPropagationHelper has a high memory overhead #1242

Open
@iuliiasobolevska

Description

@iuliiasobolevska

Hi Folks,

A canary run on one of our high-RPS services showed a significant performance degradation when upgraded from [email protected] to 1.4.0. We skipped the last OSS Spring Boot 3.4 version (3.4.7) and jumped on 3.5, so we have never tested [email protected].

The flamegraphs show that ContextPropagationHelper.isCancelled() method allocates 3GB of memory:

Image

Potential issues:

  1. https://github.com/spring-projects/spring-graphql/blob/main/spring-graphql/src/main/java/org/springframework/graphql/execution/ContextPropagationHelper.java#L128-L129 creates a publisher that's stored in context. Shall there be a cleanup mechanism to remove it from the context?
  2. ContextPropagationHelper.bindCancelFrom() calls: https://github.com/spring-projects/spring-graphql/blob/main/spring-graphql/src/main/java/org/springframework/graphql/execution/ContextDataFetcherDecorator.java#L127-L134 may be creating additional reactive chains that maintain references.
  3. https://github.com/spring-projects/spring-graphql/blob/main/spring-graphql/src/main/java/org/springframework/graphql/execution/ContextPropagationHelper.java#L143 repeatedly converts Mono to Future with Futures and their associated reactive chains potentially accumulating in memory.

Metadata

Metadata

Assignees

Labels

in: coreIssues related to config and core supportstatus: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions