Skip to content

RespServerSession RESP3 update #1223

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

Merged
merged 41 commits into from
Jun 12, 2025
Merged

Conversation

prvyk
Copy link
Contributor

@prvyk prvyk commented May 25, 2025

This PR has two main goals:

  1. Further update RESP3 support.
  2. Save on boilerplate in RespServerSession output.

The former is done by fixing various cases for RESP3 null/double and adding verbatim string support. The latter is done by adding output functions to RespServerSession (in a separate file), but the PR holds off on use till performance implications are fully checked. Also some misc. RESP2 updates (redis-cli expects an extra newlines in CLIENT INFO/LIST, these commands should emit Bulk, not simple strings).

@prvyk prvyk force-pushed the resp3serversession branch 3 times, most recently from 2159e54 to 2b77659 Compare May 25, 2025 17:04
@badrishc
Copy link
Collaborator

This is a lot of refactoring and depending on .NET's force inlining capability. We need to make sure there are no performance regressions due to e.g. saturating the inline limits that .NET places internally.

Also, see the BDN results here and identify any regressions: ee395dc#comments

There seems to be general degradations all over the place.

@badrishc
Copy link
Collaborator

Would it be possible to break this PR up into two parts: (1) the force-inlined-method version of while() ... SendAndReset(); and (2) all the other improvements/bugfixes that have no perf impact. The latter is easier to merge, whereas the former still needs better understanding of perf implications.

@prvyk
Copy link
Contributor Author

prvyk commented May 30, 2025

Yes, I was already working on that, will update the PR a bit later.

@prvyk prvyk force-pushed the resp3serversession branch from a293585 to c4dbd56 Compare May 30, 2025 20:16
Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Great work here! Thanks for spending time on this, looks good to me overall.

A main concern I have is that this is not really tested. We might want to start by adding a RESP3 test case wherever we call ConnectionMultiplexer.Connect(TestUtils.GetConfig()) and set the protocol parameter in GetConfig. Thoughts?

@prvyk
Copy link
Contributor Author

prvyk commented Jun 3, 2025

Great work here! Thanks for spending time on this, looks good to me overall.

A main concern I have is that this is not really tested. We might want to start by adding a RESP3 test case wherever we call ConnectionMultiplexer.Connect(TestUtils.GetConfig()) and set the protocol parameter in GetConfig. Thoughts?

The question is what we test. Do we test that RESP3 output is working at all? Take a command with slightly differing output and ensure it's different? Or maybe test StackExchange is working in RESP3 mode?

There's a test for the first. Maybe we can join in testing the latter two by adding a parameter to certain testcases to set protocol version, and let StackExchange do the output test.

@TalZaccai
Copy link
Contributor

Great work here! Thanks for spending time on this, looks good to me overall.
A main concern I have is that this is not really tested. We might want to start by adding a RESP3 test case wherever we call ConnectionMultiplexer.Connect(TestUtils.GetConfig()) and set the protocol parameter in GetConfig. Thoughts?

The question is what we test. Do we test that RESP3 output is working at all? Take a command with slightly differing output and ensure it's different? Or maybe test StackExchange is working in RESP3 mode?

There's a test for the first. Maybe we can join in testing the latter two by adding a parameter to certain testcases to set protocol version, and let StackExchange do the output test.

Yup I was more concerned with the latter for now, check that the client that we use does not break.

@prvyk prvyk force-pushed the resp3serversession branch 6 times, most recently from 2464ad2 to b81cde1 Compare June 5, 2025 02:31
@prvyk
Copy link
Contributor Author

prvyk commented Jun 5, 2025

Great work here! Thanks for spending time on this, looks good to me overall.
A main concern I have is that this is not really tested. We might want to start by adding a RESP3 test case wherever we call ConnectionMultiplexer.Connect(TestUtils.GetConfig()) and set the protocol parameter in GetConfig. Thoughts?

The question is what we test. Do we test that RESP3 output is working at all? Take a command with slightly differing output and ensure it's different? Or maybe test StackExchange is working in RESP3 mode?
There's a test for the first. Maybe we can join in testing the latter two by adding a parameter to certain testcases to set protocol version, and let StackExchange do the output test.

Yup I was more concerned with the latter for now, check that the client that we use does not break.

That turned out to be very useful. There were APIs which ran commands and read their output into variables. These commands could both output directly (so RESP3 change) and could be read, and the APIs was not able to read RESP3 output. The previous RESP3 PR had not accounted for this hack.

This was fixed with a mix of forcing some commands to RESP2 when we know the output is just read into variables (ZMPOP, ZRANGESTORE), and extending some reading code to handle RESP3 types and array-in-array (ProcessRespArrayOutput in Common.cs).

In 515c358 the entire testsuit was temporarily modified to run StackExchange via RESP3 and it passed (the two failures are sporadic and unrelated). This was later reverted to the default RESP2.

ZDIFF has a minor issue where ZDIFF z nx (z exists, nx does not) doesn't output z, but fixing it interfered with some tests so another time.

Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for addressing all my comments!

@prvyk prvyk force-pushed the resp3serversession branch 3 times, most recently from a6e45f8 to dba54c5 Compare June 7, 2025 17:05
@prvyk
Copy link
Contributor Author

prvyk commented Jun 7, 2025

LGTM! Thanks for addressing all my comments!

Two minor changes since then (following 06f6cd0: #1241 showed that some APIs can/should read NULL and the underlying TryReadSignedLengthHeader wasn't updated for RESP3 - added some code for it, it doesn't conflict with that PR, nor with what the function already did (it already accounted for RESP2 NULL, and callers already checked length >= 0 when needed).

It also turned out that HELLO returned proto field as BulkString and not integer, and some client libraries don't like it (they check it to see HELLO 3 worked, and then they get "3", do "3" != 3 and panic). Fixed that. Also, id field was oddly hardcoded when it should be connection id, fixed that too.

Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Added a few more comments following the latest changes...

Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Added a few additional comments to the recent changes.

prvyk added 27 commits June 12, 2025 04:08
…ANDFIELD api to work without downgrading RESP version.
ZDIFF did not handle the where all keys except the first did not exist in DB correctly, since the initial pair was not initialized in advance.

Add more tests.
…detection, so we better check after the call. If we do that check, we might as well delete the previous check.
@prvyk prvyk force-pushed the resp3serversession branch from ddf6771 to 378fea3 Compare June 12, 2025 01:12
Copy link
Contributor

@TalZaccai TalZaccai left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

@TalZaccai TalZaccai merged commit c4b997b into microsoft:main Jun 12, 2025
26 checks passed
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.

4 participants