Skip to content

perf(endpoints): reuse precomputed endpoint hashes on derived collections - #7

Closed
christianscott wants to merge 1 commit into
ep-mem/metadatafrom
ep-mem/hash-reuse
Closed

perf(endpoints): reuse precomputed endpoint hashes on derived collections#7
christianscott wants to merge 1 commit into
ep-mem/metadatafrom
ep-mem/hash-reuse

Conversation

@christianscott

Copy link
Copy Markdown

FinalBackendEndpoints and GatewayBackendClientCertificateVariantEndpoints
cloned EndpointsForBackend by re-Adding every endpoint, which re-ran
hashEndpoints -> HashProtoWithHasher (a full proto marshal) per endpoint
per copy per recompute. Add ReuseEndpointsFrom, which copies the endpoint
entries (cloned slices, no append aliasing) and reuses the precomputed
epsEqualityHash, mixing in the copy's own upstreamHash for backend
identity. The resulting equality hashes are byte-identical to the re-Add
path, including the empty endpoint set (upstreamHash) and a non-empty set
whose xor'd hash is zero (hash(0, upstreamHash)); emptiness is determined
by endpoint count, not hash value.

Benchmark: ~1088 B/endpoint copied -> ~16 B/endpoint, ~300x faster at 10k
endpoints.

Signed-off-by: Christian Scott christian@modal.com


Stack created with GitHub Stacks CLIGive Feedback 💬

…ions

FinalBackendEndpoints and GatewayBackendClientCertificateVariantEndpoints
cloned EndpointsForBackend by re-Adding every endpoint, which re-ran
hashEndpoints -> HashProtoWithHasher (a full proto marshal) per endpoint
per copy per recompute. Add ReuseEndpointsFrom, which copies the endpoint
entries (cloned slices, no append aliasing) and reuses the precomputed
epsEqualityHash, mixing in the copy's own upstreamHash for backend
identity. The resulting equality hashes are byte-identical to the re-Add
path, including the empty endpoint set (upstreamHash) and a non-empty set
whose xor'd hash is zero (hash(0, upstreamHash)); emptiness is determined
by endpoint count, not hash value.

Benchmark: ~1088 B/endpoint copied -> ~16 B/endpoint, ~300x faster at 10k
endpoints.

Signed-off-by: Christian Scott <christian@modal.com>
@christianscott

Copy link
Copy Markdown
Author

Reopened against kgateway-dev/kgateway

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.

1 participant