Cache sticky endpoint channels#2993
Open
schlosna wants to merge 5 commits into
Open
Conversation
Generate changelog in
|
ef6dbdb to
0617986
Compare
0617986 to
860dd5f
Compare
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview💡 Improvements
|
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.
Before this PR
Dialogue clients that make heavy use of sticky channels incur a significant construction overhead (e.g. see palantir/conjure-java#2869 ) leading to per-endpoint
TypeMarkeranonymous classes,
ExceptionDeserializerArgsinstances, andDeserializerfields,causing excessive allocations on high throughput services.
This adds unnecessary overhead for conjure clients that use sticky channels such as ⛰️ clients via e.g.
DataServiceAsync#of(com.palantir.dialogue.EndpointChannelFactory, com.palantir.dialogue.ConjureRuntime).See #2647 which was a basis for this PR.
After this PR
==COMMIT_MSG==
Summary
StickyEndpointChannelsFactoryinterface — replaces theSupplier<Channel>return type fromStickyEndpointChannels2.create()andDialogueChannel.stickyChannels()with a typedstickyChannel()method.DialogueChannelnow directly implements this interface, andDialogueChannel.stickyChannels()is deprecated in favor ofstickyChannel().CachingEndpointChannelFactory— encapsulates the CaffeineLoadingCache<Endpoint, EndpointChannel>withdelegate::endpointas the loader into a reusableEndpointChannelFactoryimplementation. Cache size is configurable viaConfig.maxEndpointCacheSize()(default 1000), and caching is bypassed when set to<= 0.StickyEndpointChannels2internals — removes theStickyEndpointChannels2EndpointFactorySupplierandStickyEndpointChannelinner classes; queue override attachment and sticky routing are now inlined inStickyChannel2.endpoint(), reducing indirection.ReloadingClientFactory—InternalDialogueChannelnow extendsStickyEndpointChannelsFactoryinstead of declaring its ownstickyChannels()method, and callers use the newstickyChannel()API directly.Test plan
StickyEndpointChannels2Testpasses (caching behavior is identical, just encapsulated)SimulationTestpasses and regenerated simulation resources reflect updated sticky channel behaviorReloadingClientFactoryTestpasses with the newstickyChannel()API==COMMIT_MSG==
Possible downsides?
This encapsulates a cache of
Endpoint -> EndpointChannelso there will be some memory overhead; however, use of sticky channels implies these routes intend to stick around in memory and amortize overhead for benefit of throughput.