Skip to content

fix(python): [1/3] improve in-memory size estimation for queue items#4281

Draft
yunyad wants to merge 2 commits intoapache:mainfrom
yunyad:yunyad-python-side-in-mem-size
Draft

fix(python): [1/3] improve in-memory size estimation for queue items#4281
yunyad wants to merge 2 commits intoapache:mainfrom
yunyad:yunyad-python-side-in-mem-size

Conversation

@yunyad
Copy link
Contributor

@yunyad yunyad commented Mar 11, 2026

What changes were proposed in this PR?

This PR improves the in-memory size estimation logic in LinkedBlockingMultiQueue.

Previously, queue node memory accounting used sys.getsizeof(item), which may underestimate the actual memory usage of Python data items, especially when the item contains a frame-based payload.

This PR adds _estimate_in_mem_size(item) and replaces the previous direct sys.getsizeof(item) call. The new logic prefers frame-level byte size information when available, and falls back to sys.getsizeof(item) otherwise.

Any related issues, documentation, discussions?

How was this PR tested?

Was this PR authored or co-authored using generative AI tooling?

No.

@yunyad yunyad self-assigned this Mar 11, 2026
@yunyad yunyad marked this pull request as draft March 11, 2026 19:20
@yunyad yunyad changed the title fix(python): improve in-memory size estimation for queue items fix(python): [1/3] improve in-memory size estimation for queue items Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant