Add ExecuteResp vs Execute allocation/time benchmark - #3215
Merged
Conversation
…sp/ExecuteRespAsync HSET (32 fields) + HGETALL against a real local server, contrasting the classic object[]/RedisResult path against ExecuteResp's RedisKeyOrValue/RespResult path. Each call rents/leases its own buffer rather than sharing one across iterations, to match a single realistic call rather than an amortized-lease scenario. Field values are plain integers and field names are precomputed once, so the measured allocation reflects what Execute/ExecuteResp themselves cost rather than string concatenation in the benchmark code; both benchmarks return a tally read back from the server as a correctness check that the two paths agree. Also re-enables the StackExchange.Redis ProjectReference, previously commented out due to a supposed AsciiHash conflict that no longer reproduces - the generated AsciiHash classes are internal and this project has no InternalsVisibleTo access to them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExecuteRespBenchmarks:HSET(32 fields) +HGETALLagainst a real local server, comparingExecute/ExecuteAsync(object[]args, materializedRedisResult[]) againstExecuteResp/ExecuteRespAsync(RedisKeyOrValue[]rented per call, read viaRespResult/AggregateChildren/ReadInt64, disposed per call).[GlobalSetup], so the measured allocation reflects whatExecute/ExecuteRespthemselves cost rather than string-concatenation noise common to both benchmarks.StackExchange.RedisProjectReferencein the benchmarks csproj, previously commented out for a supposedAsciiHashconflict with this project's own raw-generated-code benchmarks. That conflict doesn't reproduce: the library's[AsciiHash]-attributed classes areinternal, and this project has noInternalsVisibleToaccess to them, so nothing collides. Verified clean builds onnet10.0,net8.0, andnet481.Measured (short run, illustrative): 84% less allocation per call (832 B vs 5280 B), time roughly a wash (network round trip dominates wall-clock) - consistent with
docs/Execute.md's existing claim. Also spot-checked with an ad hoc allocation-scaling diagnostic (not included) that both the outbound argument buffer and the inbound leased response buffer amortize correctly - allocation-per-call stayed flat across multiple orders of magnitude of payload size on both the write and read sides, so the residual per-call cost is fixedTask/tracking-object overhead, not a buffer-pooling defect.Test plan
net10.0,net8.0,net481docker compose -f tests/RedisConfigs/docker-compose.yml up -d --wait) withdotnet run -c Release -f net10.0 -- --filter "*ExecuteRespBenchmarks*"; both benchmarks pass their internal tally correctness check