Skip to content

Conversation

@nilanshu-sharma
Copy link
Collaborator

@nilanshu-sharma nilanshu-sharma commented Nov 19, 2025

  1. Adding Custom return types and standard error for hrandfield based on the input arguments to the hrandfield command. The command returns either:
  • A single hash field if no arguments are provided
  • An array of hash field if called with COUNT but without WITHVALUES
  • An array of HashField if called with COUNT and WITHVALUES
  1. Also restoring platform availability macros causing builds to fail

====================================================================================

Following test show the RESP return types for RESP2 and RESP3.

127.0.0.1:6379> hset myhash field1 value1 field2 value2
(integer) 2
  • RESP2 will return a flat array of bulkString
127.0.0.1:6379> hrandfield myhash 2 WITHVALUES
1) "field1"
2) "value1"
3) "field2"
4) "value2"
  • RESP3 will return an array of arrays
127.0.0.1:6379> hrandfield myhash 2 WITHVALUES
1) 1) "field1"
   2) "value1"
2) 1) "field2"
   2) "value2"

@github-actions
Copy link

github-actions bot commented Nov 19, 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 '6f27407982dc' 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 75 78 80 81 82 82 82 6
pull_request 74 76 78 79 85 85 85 6
Δ -1 -2 -2 -2 3 3 3 0
Improvement % 1 3 2 2 -4 -4 -4 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 75 77 79 82 86 87 87 28
pull_request 71 74 78 84 87 88 88 23
Δ -4 -3 -1 2 1 1 1 -5
Improvement % 5 4 1 -2 -1 -1 -1 -5

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 11 11 11 8
pull_request 7 8 8 10 11 11 11 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 34 34 34 34 34 6
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 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 5
Δ 0 0 0 0 0 0 0 -1
Improvement % 0 0 0 0 0 0 0 -1

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 19
pull_request 0 0 0 0 0 0 0 19
Δ 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 728
pull_request 0 0 0 0 0 0 0 740
Δ 0 0 0 0 0 0 0 12
Improvement % 0 0 0 0 0 0 0 12

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 1816
pull_request 0 0 0 0 0 0 0 1878
Δ 0 0 0 0 0 0 0 62
Improvement % 0 0 0 0 0 0 0 62

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 350
pull_request 0 0 0 0 0 0 0 355
Δ 0 0 0 0 0 0 0 5
Improvement % 0 0 0 0 0 0 0 5

@nilanshu-sharma nilanshu-sharma marked this pull request as draft November 20, 2025 00:11
Nilanshu Sharma added 2 commits November 20, 2025 18:22
Signed-off-by: Nilanshu Sharma <[email protected]>
@nilanshu-sharma nilanshu-sharma changed the title [WIP]: Standard return types and errors for hrandfield Standard return types and errors for hrandfield Nov 21, 2025
@nilanshu-sharma nilanshu-sharma marked this pull request as ready for review November 21, 2025 02:38
/// Get multiple random field-value pairs when HRANDFIELD was called with COUNT and WITHVALUES
/// - Returns: Array of HashEntry (field-value pairs), or empty array if key doesn't exist
/// - Throws: RESPDecodeError if response format is unexpected
public func multipleFieldsWithValues() throws -> [HashEntry] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are a bunch of helper functions for decoding which you should probably use. Also this should probably be a nil value when null is returned. This can probably be replaced with

[HashEntry]?(fromRESP: token)

Copy link
Collaborator Author

@nilanshu-sharma nilanshu-sharma Dec 1, 2025

Choose a reason for hiding this comment

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

I tried using [HashEntry]?(fromRESP: token) for multipleFieldsWithValues(). It did work for RESP3 which encodes responses as an array of arrays, because HashEntry can convert a RESPToken encoded as an array to self.

But RESP2 responses will fail because a flat array can't be converted to HashEntry.

So If responses are RESP3 I'll use [HashEntry]?(fromRESP: token) but I'll use the custom logic in case of flat array.

@adam-fowler adam-fowler merged commit b060412 into main Dec 2, 2025
14 of 15 checks passed
@adam-fowler adam-fowler deleted the custom-response-hrandfield branch December 2, 2025 08:26
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