Skip to content

contrib-sipproxy: rework sipproxy stats#24165

Merged
mattklein123 merged 12 commits intoenvoyproxy:mainfrom
nokia:rework-stats
Dec 2, 2022
Merged

contrib-sipproxy: rework sipproxy stats#24165
mattklein123 merged 12 commits intoenvoyproxy:mainfrom
nokia:rework-stats

Conversation

@durd07
Copy link
Copy Markdown
Member

@durd07 durd07 commented Nov 23, 2022

Signed-off-by: Felix Du durd07@gmail.com

Commit Message: rework sipproxy stats to improve performance
Additional Description:
Risk Level: Low
Testing: Ut/Mt
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Signed-off-by: Felix Du <durd07@gmail.com>
@jmarantz
Copy link
Copy Markdown
Contributor

CI needs to be sorted out. Thanks!

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #24165 (comment) was created by @jmarantz.

see: more, trace.

Felix Du and others added 4 commits November 27, 2022 12:42
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Signed-off-by: Felix Du <durd07@gmail.com>
Signed-off-by: Felix Du <durd07@gmail.com>
Signed-off-by: Felix Du <durd07@gmail.com>
@durd07
Copy link
Copy Markdown
Member Author

durd07 commented Nov 28, 2022

@dorisd0102 Please help to review this PR.
Thanks.

@dorisd0102
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

/wait

Comment on lines +36 to +42
try {
if (cache_manager_.at(type, key) != val) {
should_update_tra = true;
}
} catch (std::out_of_range) {
should_update_tra = true;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please avoid using exceptions for basic control flow. Just use find(). Same elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi @mattklein123 ,
Thanks for your comments, but why exceptions are not recommended?
I want to implement a similiar method like std::map::at

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Because a) we are trying to avoid exceptions at this point and b) this is not a good use of exceptions. Use find to return an iterator.

Comment on lines +262 to +264
/**
* NOTE: This may throw exception std::out_of_range if type or key doesn't exist.
*/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment. Don't use exceptions for this.

Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

/wait

Comment on lines +35 to +37
bool should_update_tra = true;
if (cache_manager_.contains(type, key) && (cache_manager_.at(type, key) == val)) {
should_update_tra = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can void a double lookup by using find(). Same elsewhere.

Comment on lines 263 to 265
* NOTE: This may throw exception std::out_of_range if type or key doesn't exist.
* use contains(type, key) to check exist first.
*/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rework to always use find. Never us at.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mattklein123 Thanks for your comments.

Firstly I want to implement a find method like what does as std::map, but I can't figure out the solution because different iterator maybe returned in a nested map, so write a method called at which return empty value if not exist.

[[ret_type]] find(const T& type, const K& key) {
  auto it = caches_.find(type);
  if (it != caches_.cend()) {
    return it->second.find(key);    // iterator of Cache<K, V>::iterator
   } else {
    return [[ the iterator of caches_ ]]
  }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

drive-by comment: if your goal is to return an optional value if it's in one of several collections, you could return absl::optional, or OptRef (see envoy/common/optref.h) if you want V to be a reference.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @jmarantz , I already aware of this, but I don't want to make thing more complex.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes this is what you should do, so let's please do that.

/wait

Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Felix Du added 3 commits December 2, 2022 02:42
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
Signed-off-by: Felix Du <felix.du@nokia-sbell.com>
@durd07
Copy link
Copy Markdown
Member Author

durd07 commented Dec 2, 2022

@mattklein123 @jmarantz
Thanks for your comments, all of them are addressed.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit e849d5e into envoyproxy:main Dec 2, 2022
jpsim added a commit to alyssawilk/envoy that referenced this pull request Dec 2, 2022
* origin/main:
  Start slow start window on first successful HC, make slow start re-enterable (envoyproxy#23946)
  contrib-sipproxy: rework sipproxy stats (envoyproxy#24165)
  build(deps): bump github/codeql-action from 2.1.32 to 2.1.35 (envoyproxy#24292)
  build(deps): bump node from `c59fb39` to `80844b6` in /examples/ext_authz/auth/http-service (envoyproxy#24274)
  build(deps): bump actions/upload-artifact from 2 to 3 (envoyproxy#24121)
  build(deps): bump mysql from `96439dd` to `66efaaa` in /examples/mysql (envoyproxy#24273)
  build(deps): bump grpcio from 1.50.0 to 1.51.1 in /examples/grpc-bridge/client (envoyproxy#24272)
  Allow mobile/library/common/jni/ to be built on non-Android platforms. (envoyproxy#24299)
  generic proxy: added drain support to generic proxy to doing graceful closes on connections when possible (envoyproxy#24220)
  Reduce Route/VirtualHost memory utilization by avoiding RateLimitPolicy instances when not needed (envoyproxy#24243)
  Reduce VirtualHost memory utilization by avoiding CatchAllVirtualCluster when not needed (envoyproxy#24182)
  Fix mobile/tools/check_format.sh to re-apply envoyproxy#2698 (envoyproxy#24300)
  upstream: don't require `source_address` in `upstream_bind_config` (envoyproxy#24250)
  Quiche roll 20221201150327 (envoyproxy#24290)

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim added a commit that referenced this pull request Dec 2, 2022
…/docs/sphinx-5.3.0

* origin/main: (50 commits)
  ci: Bump mobile build images (#24317)
  ci: update llvm on bazel CI (#24296)
  ci: Fix flaky coverage limit (#24320)
  ci: Fix change detection (part 2) (#24264)
  Start slow start window on first successful HC, make slow start re-enterable (#23946)
  contrib-sipproxy: rework sipproxy stats (#24165)
  build(deps): bump github/codeql-action from 2.1.32 to 2.1.35 (#24292)
  build(deps): bump node from `c59fb39` to `80844b6` in /examples/ext_authz/auth/http-service (#24274)
  build(deps): bump actions/upload-artifact from 2 to 3 (#24121)
  build(deps): bump mysql from `96439dd` to `66efaaa` in /examples/mysql (#24273)
  build(deps): bump grpcio from 1.50.0 to 1.51.1 in /examples/grpc-bridge/client (#24272)
  Allow mobile/library/common/jni/ to be built on non-Android platforms. (#24299)
  generic proxy: added drain support to generic proxy to doing graceful closes on connections when possible (#24220)
  Reduce Route/VirtualHost memory utilization by avoiding RateLimitPolicy instances when not needed (#24243)
  Reduce VirtualHost memory utilization by avoiding CatchAllVirtualCluster when not needed (#24182)
  Fix mobile/tools/check_format.sh to re-apply #2698 (#24300)
  upstream: don't require `source_address` in `upstream_bind_config` (#24250)
  Quiche roll 20221201150327 (#24290)
  Cleanup threading/ownership semantics of PlatformBridgeCertValidator (#2713)
  Add unit tests of the PlatformBridgeCertValidator (#2704)
  ...

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim added a commit that referenced this pull request Dec 2, 2022
…/docs/pygments-2.13.0

* origin/main: (25 commits)
  ci: Bump mobile build images (#24317)
  ci: update llvm on bazel CI (#24296)
  ci: Fix flaky coverage limit (#24320)
  ci: Fix change detection (part 2) (#24264)
  Start slow start window on first successful HC, make slow start re-enterable (#23946)
  contrib-sipproxy: rework sipproxy stats (#24165)
  build(deps): bump github/codeql-action from 2.1.32 to 2.1.35 (#24292)
  build(deps): bump node from `c59fb39` to `80844b6` in /examples/ext_authz/auth/http-service (#24274)
  build(deps): bump actions/upload-artifact from 2 to 3 (#24121)
  build(deps): bump mysql from `96439dd` to `66efaaa` in /examples/mysql (#24273)
  build(deps): bump grpcio from 1.50.0 to 1.51.1 in /examples/grpc-bridge/client (#24272)
  Allow mobile/library/common/jni/ to be built on non-Android platforms. (#24299)
  generic proxy: added drain support to generic proxy to doing graceful closes on connections when possible (#24220)
  Reduce Route/VirtualHost memory utilization by avoiding RateLimitPolicy instances when not needed (#24243)
  Reduce VirtualHost memory utilization by avoiding CatchAllVirtualCluster when not needed (#24182)
  Fix mobile/tools/check_format.sh to re-apply #2698 (#24300)
  upstream: don't require `source_address` in `upstream_bind_config` (#24250)
  Quiche roll 20221201150327 (#24290)
  Cleanup threading/ownership semantics of PlatformBridgeCertValidator (#2713)
  Add unit tests of the PlatformBridgeCertValidator (#2704)
  ...

Signed-off-by: JP Simard <jp@jpsim.com>
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.

4 participants