Skip to content

Reduce memory use of the waiting_tasks metric - #8009

Open
aKlimau wants to merge 1 commit into
pulp:mainfrom
aKlimau:tasks-in-memory
Open

Reduce memory use of the waiting_tasks metric#8009
aKlimau wants to merge 1 commit into
pulp:mainfrom
aKlimau:tasks-in-memory

Conversation

@aKlimau

@aKlimau aKlimau commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

count_waiting_tasks_for_metric() now streams reserved_resources_record via values_list().iterator() instead of materializing deferred Task instances.

The "shared:" split is moved into redis_locks._split_reserved_resources().

ref #7986

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@aKlimau aKlimau changed the title Reduce memory use of the waiting_tasks metric Reduce memory use of the waiting_tasks metric #7986 Aug 25, 2026
@aKlimau aKlimau changed the title Reduce memory use of the waiting_tasks metric #7986 Reduce memory use of the waiting_tasks metric Aug 25, 2026
@aKlimau

aKlimau commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

After discussing all the suggested solutions in #7986 with claude, it looks like solutions 2 and 3 would have a positive impact on memory usage with no behavioral change.

METRIC_HEARTBEAT_INTERVAL is a separate change that would make metrics not as fresh, so we'd need to decide weather it's worth.

And using Redis cache doesn't save us much, since the computation is always done by a single worker and runs once per cycle. So introducing a round trip and another potential point of failure doesn't seem worth it to me.

@aKlimau

aKlimau commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@decko by any chance do we have a way to measure the performance impact of such changes? (Memory allocation during count_waiting_tasks_for_metric() call)

Comment thread pulpcore/tasking/redis_locks.py Outdated
"""
Split a ``reserved_resources_record`` array into (exclusive, shared) resource names.

Shared reservations are stored with a ``"shared:"`` prefix; exclusive ones are bare.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the double backticks please

The metric scans every waiting/running task but only needs each task's
reserved resources. Fetch just those instead of building a model object
per row.

ref pulp#7986

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants