You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2021/11/10 01:47:54 UTC

[GitHub] [incubator-brpc] serverglen opened a new issue #1601: 关于实现bvar::WindowEx的几点想法

serverglen opened a new issue #1601:
URL: https://github.com/apache/incubator-brpc/issues/1601


   # bvar::Window的问题?
   * bvar中的bvar::Window和bvar::PerSecond统计用起来不是很方便,依赖于一个单独的计数器
   
   # bvar::WindowEx的实现思考
   * 重新实现bvar::WindowEx和bvar::PerSecondEx用来替代bvar::Window和bvar::PerSecond
   * 不依赖其他的计数器,方便使用
   
   # bvar::WindowEx 
   获得之前一段时间内的统计值。WindowEx是独立存在的,不依赖其他的计数器,需要给它发送数据。出于性能考虑,WindowEx每秒对数据做一次统计,在最差情况下,WindowEx的返回值有1秒的延时。
   如何使用?
   `
   const int window_size = 60;
    
   // sum_minute.get_value()是60秒内的累加值,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   bvar::WindowEx<bvar::Adder<int>, window_size> sum_minute("sum_minute");
   sum_minute << 1 << 2 << 3;
    
   // max_minute.get_value()是60秒内的最大值,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   bvar::WindowEx<bvar::Maxer<int>, window_size> max_minute("max_minute");
   max_minute << 1 << 2 << 3;
    
   // min_minute.get_value()是60秒内的最小值,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   bvar::WindowEx<bvar::Miner<int>, window_size> min_minute("min_minute");
   min_minute << 1 << 2 << 3;
   `
   # bvar::WindowEx和bvar::Window的区别
   * bvar::Window 不能独立存在,必须依赖于一个已有的计数器。Window会自动更新,不用给它发送数据;window_size是通过构造函数参数传递的。
   * bvar::WindowEx 是独立存在的,不依赖其他的计数器,需要给它发送数据。使用起来比较方便;window_size是通过模板参数传递的,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   
   # bvar::PerSecondEx
   获得之前一段时间内平均每秒的统计值。它和WindowEx基本相同,除了返回值会除以时间窗口之外。
   如何使用
   `
   const int window_size = 60;
    
   // sum_per_second.get_value()是60秒内*平均每秒*的累加值,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   bvar::PerSecondEx<bvar::Adder<int>, window_size> sum_per_second("sum_per_second");
   sum_per_second << 1 << 2 << 3;
   `
   
   # bvar::PerSecondEx和bvar::WindowEx的区别
   获得之前一段时间内平均每秒的统计值。它和WindowEx基本相同,除了返回值会除以时间窗口之外。
   
   # bvar::PerSecondEx和bvar::PerSecond的区别
   * bvar::PerSecond 不能独立存在,必须依赖于一个已有的计数器。PerSecond会自动更新,不用给它发送数据;window_size是通过构造函数参数传递的。
   * bvar::PerSecondEx 是独立存在的,不依赖其他的计数器,需要给它发送数据。使用起来比较方便;window_size是通过模板参数传递的,省略最后一个window_size(时间窗口)的话默认为bvar_dump_interval。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wwbmmm commented on issue #1601: 关于实现bvar::WindowEx的提议

Posted by GitBox <gi...@apache.org>.
wwbmmm commented on issue #1601:
URL: https://github.com/apache/incubator-brpc/issues/1601#issuecomment-987864110


   这个改动的主要目的不是使用便利性,更重要的是对于多维度的bvar,要求子bvar类型都能独立计数和统计,而不依赖于其它的bvar,所以增加了WindowEx和PerSecondEx。不过顺便也提升了使用便利性。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] serverglen commented on issue #1601: 关于实现bvar::WindowEx的提议

Posted by GitBox <gi...@apache.org>.
serverglen commented on issue #1601:
URL: https://github.com/apache/incubator-brpc/issues/1601#issuecomment-966308974


   已实现,PR: #1603 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wwbmmm edited a comment on issue #1601: 关于实现bvar::WindowEx的提议

Posted by GitBox <gi...@apache.org>.
wwbmmm edited a comment on issue #1601:
URL: https://github.com/apache/incubator-brpc/issues/1601#issuecomment-987864110


   这个改动的主要目的不是使用便利性,更重要的是为了实现多维度的bvar功能(#1322),要求子bvar类型都能独立计数和统计,而不依赖于其它的bvar,所以增加了WindowEx和PerSecondEx。不过顺便也提升了使用便利性。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org