Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplemented the MemQueue class to avoid unordered inserts #295

Merged
merged 2 commits into from Jan 13, 2023

Conversation

tarekziade
Copy link
Contributor

I closed #281 because I figured out that we did not have a race condition.

See #281 (comment)

But then I realized the implementation can lead to unordered inserts in the queue. So this new patch reintroduces the change which does respect the ordering.

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@artem-shelkovnikov artem-shelkovnikov left a comment

Choose a reason for hiding this comment

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

I tried to review, but it's still pretty hard to understand what's going on. Is it possible to add more tests/comments or refactor to make the logic easier to read?

Comment on lines +73 to +74
quotient, _ = divmod(mem_queue_duration, queue_duration)
assert quotient < 30
Copy link
Member

Choose a reason for hiding this comment

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

Why 30? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arbitrary number. It's just set to make sure the class does not get slower over time when we change it

Comment on lines +79 to +83
item = "small stuff"
queue = MemQueue(
maxmemsize=get_size(item) * 2 + 1, refresh_interval=0.1, refresh_timeout=30
)
max_size = 0
Copy link
Member

Choose a reason for hiding this comment

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

I think a comment would help to understand what's going on in the test. I vaguely understand it, but not 100% sure and not 100% sure what is the actual problem.

@tarekziade
Copy link
Contributor Author

I tried to review, but it's still pretty hard to understand what's going on. Is it possible to add more tests/comments or refactor to make the logic easier to read?

I can add comments, but hardly refactor because it's based on the asyncio.Queue class logic

@artem-shelkovnikov
Copy link
Member

artem-shelkovnikov commented Jan 13, 2023

I can add comments, but hardly refactor because it's based on the asyncio.Queue class logic

I see. Maybe pointing out every change to the original implementation can help?

@tarekziade
Copy link
Contributor Author

I can add comments, but hardly refactor because it's based on the asyncio.Queue class logic

I see. Maybe pointing out every change to the original implementation can help?

this is what I did with the two comments (1/ 2/) in the cod, we have two changes -- the original method is here https://github.com/python/cpython/blob/3.10/Lib/asyncio/queues.py#L111

Copy link
Member

@artem-shelkovnikov artem-shelkovnikov left a comment

Choose a reason for hiding this comment

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

LGTM

@tarekziade tarekziade merged commit 2cde08e into main Jan 13, 2023
@tarekziade tarekziade deleted the tarekziade/doc branch January 13, 2023 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants