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

Remove the superflous SocketBuffer from asyncio PythonParser #2418

Merged
merged 5 commits into from
Oct 30, 2022

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Oct 15, 2022

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

asyncio PyhonParser was using a SocketBuffer class to store incoming data. This is probably a carry-over from the
non-async version, but in asyncio, it is not needed. We can read directly from the _stream which is a StreamReader with
an internal buffer of 64KB.

This change removes redundant code and speeds up python parsing by relying on already-provided buffering and readline() functionality.

@kristjanvalur
Copy link
Contributor Author

In addition, the socket_read_size is now more or less unused. it is used by HiredisParser as the batch size to move between the input stream and the hiredis parser. I'd like to remove it from the Parsers, use an arbitrary large value in the HiredisParser, and instead use it when instantiating the stream, using open_connection(limit=socket_read_size) or similar which will directly affect read buffering.

@kristjanvalur kristjanvalur force-pushed the dev/remove_socketbuffer branch 3 times, most recently from 326086a to 4937db7 Compare October 16, 2022 10:12
@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2022

Codecov Report

Base: 92.03% // Head: 92.03% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (f4aee4c) compared to base (bea00b1).
Patch coverage: 84.37% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2418      +/-   ##
==========================================
- Coverage   92.03%   92.03%   -0.01%     
==========================================
  Files         110      110              
  Lines       28737    28677      -60     
==========================================
- Hits        26448    26392      -56     
+ Misses       2289     2285       -4     
Impacted Files Coverage Δ
redis/asyncio/connection.py 86.38% <81.48%> (-0.75%) ⬇️
tests/test_asyncio/test_connection.py 98.57% <100.00%> (+0.02%) ⬆️
tests/test_cluster.py 96.96% <0.00%> (ø)
tests/test_asyncio/test_search.py 98.61% <0.00%> (+0.34%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kristjanvalur
Copy link
Contributor Author

@dvora-h , is this something you'd consided including in the next release? It sort of forms the conclusion to a lot of my asyncio related simplifications in the library.

Copy link
Collaborator

@dvora-h dvora-h left a comment

Choose a reason for hiding this comment

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

@kristjanvalur Thanks for this!
Can you please remove the timeseries tests changes from this PR?
Because: 1. It is not related here, we prefer to do such things in separate PR's
2. Following changes in the module, this is happening there now and there is no need for it... (we have already changed the test accordingly)

@kristjanvalur
Copy link
Contributor Author

Sure, I can remove that. Please understand, I find myself often adding unrelated fixes to unittests when doing these pull requests, because the unittests are sometimes very flaky. Of course they're not part of the PR as such, but I do like my PRs to pass the CI pipeline regardless.

@kristjanvalur
Copy link
Contributor Author

Regarding the socket_read_size, I'll make a separate PR for that once this one is merged, so that you can evaluate that change separately.

@dvora-h dvora-h merged commit 16270e4 into redis:master Oct 30, 2022
@dvora-h
Copy link
Collaborator

dvora-h commented Oct 30, 2022

Thanks @kristjanvalur for all your hard work!

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.

3 participants