Skip to content

Conversation

adam-fowler
Copy link
Collaborator

@adam-fowler adam-fowler commented Sep 12, 2025

Code generator will attempt to choose the correct return value for a Valkey command, but it can only do simple types like String, Int, Array of RESP Tokens. If we want to provide more complex responses we have to write some custom code. To do this

  • disable the return value generation for that command in the code generator
  • override the Response typealias in the ValkeyCommand type
  • provide a method to initialise this Response from a RESPToken.

Also in this PR

  • moved integration tests, testing commands into separate file
  • Added command test helper testCommandEncodesDecodes and use in script and server commands, will extend to others in separate PR

@adam-fowler adam-fowler marked this pull request as draft September 12, 2025 16:28
Copy link

github-actions bot commented Sep 12, 2025

✅ Pull request no significant performance differences ✅

Summary

New baseline 'pull_request' is WITHIN the 'main' baseline thresholds.

Full Benchmark Comparison

Comparing results between 'main' and 'pull_request'

Host '59d5d386876a' with 4 'x86_64' processors with 15 GB memory, running:
#18~24.04.1-Ubuntu SMP Sat Jun 28 04:46:03 UTC 2025

ValkeyBenchmarks

Client: GET benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 80 82 84 86 89 89 89 6
pull_request 81 85 85 87 89 89 89 6
Δ 1 3 1 1 0 0 0 0
Improvement % -1 -4 -1 -1 0 0 0 0

Client: GET benchmark | parallel 20 | 20 concurrent connections metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 95 100 102 105 108 109 109 24
pull_request 97 99 101 105 107 110 110 25
Δ 2 -1 -1 0 -1 1 1 1
Improvement % -2 1 1 0 1 -1 -1 1

Connection: GET benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 4 4 4 4 4 4 4 8
pull_request 4 4 4 4 4 4 4 8
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

Connection: GET benchmark – NoOpTracer metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 7 8 8 10 10 10 10 8
pull_request 7 8 8 10 10 10 10 8
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

Connection: Pipeline array benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 33 33 34 34 34 34 34 6
pull_request 33 33 33 34 34 34 34 6
Δ 0 0 -1 0 0 0 0 0
Improvement % 0 0 3 0 0 0 0 0

Connection: Pipeline benchmark metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 33 33 33 34 34 34 34 6
pull_request 33 33 33 34 34 34 34 6
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

HashSlot – {user}.whatever metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 17
pull_request 0 0 0 0 0 0 0 17
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

ValkeyCommandEncoder – Command with 7 words metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 731
pull_request 0 0 0 0 0 0 0 741
Δ 0 0 0 0 0 0 0 10
Improvement % 0 0 0 0 0 0 0 10

ValkeyCommandEncoder – Simple GET metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 1828
pull_request 0 0 0 0 0 0 0 1894
Δ 0 0 0 0 0 0 0 66
Improvement % 0 0 0 0 0 0 0 66

ValkeyCommandEncoder – Simple MGET 15 keys metrics

Malloc (total): results within specified thresholds, fold down for details.

Malloc (total) * p0 p25 p50 p75 p90 p99 p100 Samples
main 0 0 0 0 0 0 0 343
pull_request 0 0 0 0 0 0 0 359
Δ 0 0 0 0 0 0 0 16
Improvement % 0 0 0 0 0 0 0 16

Signed-off-by: Adam Fowler <[email protected]>
Signed-off-by: Adam Fowler <[email protected]>
Add testCommandEncodesDecodes helper function

Signed-off-by: Adam Fowler <[email protected]>
@adam-fowler adam-fowler marked this pull request as ready for review September 13, 2025 14:31
@adam-fowler adam-fowler added this to the 1.0 milestone Sep 25, 2025
Copy link
Collaborator

@nilanshu-sharma nilanshu-sharma left a comment

Choose a reason for hiding this comment

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

Added comments.

public func functionLoad<FunctionCode: RESPStringRenderable>(
replace: Bool = false,
functionCode: FunctionCode
) async throws -> FUNCTION.LOADResponse {
Copy link
Collaborator

Choose a reason for hiding this comment

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

To ensure consistency in readability, should we call it FUNCTION.LOAD.Response ?
And Similarly for SCRIPT based methods below. Instead of returning SCRIPT.EXISTSResponse, should we return SCRIPT.EXISTS.Response ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason I do this is to avoid the generic parameter that comes with FUNCTION.LOAD. If I returned a type that was internal to FUNCTION.LOAD it would require the generic parameter ie FUNCTION.LOAD<FunctionCode>.RESPONSE. Given the response doesn't use the generic parameter FunctionCode it doesn't make sense it include it.

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.

2 participants