Add thread local cache of overload action states#4090
Add thread local cache of overload action states#4090htuch merged 3 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Elisha Ziskind <eziskind@google.com>
htuch
left a comment
There was a problem hiding this comment.
Looks great, just one quick question and nit.
| * Get the thread-local overload action state cache. Lookups in this cache can be used as | ||
| * an alternative to registering a callback for overload action state changes. | ||
| */ | ||
| virtual const OverloadActionStateCache& getOverloadActionStateCache() PURE; |
There was a problem hiding this comment.
Nit: I might name this getOverLoadThreadLocalState(); "cache" is an overloaded concept and pointing out this is the thread-local variant makes the code a bit easier to read </bikeshed>.
There was a problem hiding this comment.
Changed to ThreadLocalOverloadState
| */ | ||
| class OverloadActionStateCache : public ThreadLocal::ThreadLocalObject { | ||
| public: | ||
| bool isActive(const std::string& action) const { |
There was a problem hiding this comment.
Since this is eventually going to be called on the data path on HCM, I guess I'm wonder out loud whether we want to do a string hash/compare on new stream? It's probably lost in the noise of the overall overhead of new stream creation. An alternative would be to establish a map from the action strings to opaque integer tags that HCM can obtain at instantiation. Seems like micro-optimization, just curious about your thoughts here.
There was a problem hiding this comment.
Good idea - changed to allow doing the map lookup at at initialization time.
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Signed-off-by: Elisha Ziskind <eziskind@google.com>
htuch
left a comment
There was a problem hiding this comment.
Great, the reference style seems optimal.
* origin/master: (38 commits) test: add tests for corner-cases around sending requests before run() starts or after run() ends. (envoyproxy#4114) perf: reduce the memory usage of LC Trie construction (envoyproxy#4117) test: moving redundant code in websocket_integration_test to utilities (envoyproxy#4127) test: make YamlLoadFromStringFail less picky about error msg. (envoyproxy#4141) rbac: add rbac network filter. (envoyproxy#4083) fuzz: route lookup and header finalization fuzzer. (envoyproxy#4116) Set content-type and content-length (envoyproxy#4113) fault: use FractionalPercent for percent (envoyproxy#3978) test: Fix inverted exact match logic in IntegrationTcpClient::waitForData() (envoyproxy#4134) Added cluster_name to load assignment config for static cluster (envoyproxy#4123) ssl: refactor ContextConfig to use TlsCertificateConfig (envoyproxy#4115) syscall: refactor OsSysCalls for deeper errno latching (envoyproxy#4111) thrift_proxy: fix oneway bugs (envoyproxy#4025) Do not crash when converting YAML to JSON fails (envoyproxy#4110) config: allow unknown fields flag (take 2) (envoyproxy#4096) Use a jittered backoff strategy for handling HdsDelegate stream/connection failures (envoyproxy#4108) bazel: use GCS remote cache (envoyproxy#4050) Add thread local cache of overload action states (envoyproxy#4090) Added TCP healthcheck capabilities to the HdsDelegate (envoyproxy#4079) secret: add secret provider interface and use it for TlsCertificates (envoyproxy#4086) ... Signed-off-by: Snow Pettersen <snowp@squareup.com>
Lookups in this cache can be used as an alternative to registering a callback for overload action state changes. Useful for objects (like the http connection manager) with dynamic lifetimes that are created after envoy initialization - currently callback registration must be done during initialization and there isn't support for unregistration. Those restrictions could be relaxed if we need to in the future but for now this keeps things simpler. For issue #373.
Risk Level: low
Testing: unit tests
Signed-off-by: Elisha Ziskind eziskind@google.com