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

feat: speed up auth phase #131

Merged
merged 1 commit into from
Oct 31, 2022
Merged

feat: speed up auth phase #131

merged 1 commit into from
Oct 31, 2022

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 31, 2022

We now try to read a whole line at a time
since there is no risk of reading too far
ahead given that the spec says:

The first octet received by the server after the \r\n of the BEGIN command from the client must be the first octet of the authenticated/encrypted stream of D-Bus messages.

Unlike all other commands, the server does not reply to the BEGIN command with an authentication command of its own. After the \r\n of the reply to the command before BEGIN, the next octet received by the client must be the first octet of the authenticated/encrypted stream of D-Bus messages.

This avoids 26 read syscalls on average

fixes #128

We now try to read a whole line at a time
since there is no risk of reading too far
ahead given that the spec says:

The first octet received by the server after the \r\n of the BEGIN command from the client must be the first octet of the authenticated/encrypted stream of D-Bus messages.

Unlike all other commands, the server does not reply to the BEGIN command with an authentication command of its own. After the \r\n of the reply to the command before BEGIN, the next octet received by the client must be the first octet of the authenticated/encrypted stream of D-Bus messages.

fixes #128
@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Base: 81.72% // Head: 81.66% // Decreases project coverage by -0.05% ⚠️

Coverage data is based on head (943ea01) compared to base (f8c67ed).
Patch coverage: 50.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #131      +/-   ##
==========================================
- Coverage   81.72%   81.66%   -0.06%     
==========================================
  Files          27       27              
  Lines        3091     3092       +1     
  Branches      597      597              
==========================================
- Hits         2526     2525       -1     
  Misses        347      347              
- Partials      218      220       +2     
Impacted Files Coverage Δ
src/dbus_fast/__version__.py 0.00% <0.00%> (ø)
src/dbus_fast/_private/unmarshaller.py 95.29% <0.00%> (ø)
src/dbus_fast/_private/_cython_compat.py 100.00% <100.00%> (ø)
src/dbus_fast/aio/message_bus.py 85.98% <100.00%> (ø)
src/dbus_fast/message_bus.py 71.00% <0.00%> (-0.38%) ⬇️

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.

@bdraco
Copy link
Member Author

bdraco commented Oct 31, 2022

60    getpid()                          = 60
60    sendto(56, "\0", 1, 0, NULL, 0)   = 1
60    getuid()                          = 0
60    sendto(56, "AUTH EXTERNAL 30\r\n", 18, 0, NULL, 0) = 18
60    recvfrom(56, "OK 27ecd1c33de69bca61bcaf91be376fc6\r\n", 1024, 0, NULL, NULL) = 37
60    sendto(56, "NEGOTIATE_UNIX_FD\r\n", 19, 0, NULL, 0) = 19
60    recvfrom(56, "AGREE_UNIX_FD\r\n", 1024, 0, NULL, NULL) = 15
60    sendto(56, "BEGIN\r\n", 7, 0, NULL, 0) = 7
60    epoll_ctl(4, EPOLL_CTL_ADD, 56, {events=EPOLLIN, data={u32=56, u64=281470681743416}}) = 0
60    sendto(56, "l\1\0\1\0\0\0\0\1\0\0\0m\0\0\0\1\1o\0\25\0\0\0/org/freedesktop/DBus\0\0\0\2\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0\3\1s\0\5\0\0\0Hello\0\0\0\6\1s\0\24\0\0\0org.freedesktop.DBus\0\0\0\0", 128, 0, NULL, 0) = 128

Looks much better now

@bdraco bdraco marked this pull request as ready for review October 31, 2022 11:57
@bdraco bdraco merged commit 3eef636 into main Oct 31, 2022
@bdraco bdraco deleted the read_full_line branch October 31, 2022 11:57
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.

Authentication is reading 2 bytes at a time
1 participant