wxbty opened a new pull request, #11352:
URL: https://github.com/apache/dubbo/pull/11352

   ## What is the purpose of the change
   
   When I was writing registry metric implement, I will  use some codes of 
metrics-api, and found that some codes might be optimized.
   
   ## Brief changelog
   
   Mainly optimize the following aspects:
   
   1. Object-oriented design optimization
   
   - The quadruple of interfaceName, methodName, group, version, which appears 
frequently and  use together, can be replaced by an object
   - Both DefaultMetricsCollector and MetricsStatComposite have the behavior of 
publishing MetricsEvent. MetricsStatComposite locates the data aggregation 
carrier and should only be responsible for the processing of internal data. 
Event registration and publishing should be managed by a separate class (refer 
to spring), and the separation of class responsibilities can be easier Scale 
and prevent single-class code bloat.
   
   2. Optimization of memory usage
   
   - Every time the method (invoke, onResponse, onError) in MetricsFilter is 
triggered, the new temporary object MetricsCollectExecutor will be created. 
This is unnecessary. Changing to the statc method can reduce the number of yong 
gc.
   - In addition, a simple object pool is used to obtain the previous quadruple 
object
   
   3. Optimization of some repetitive codes
   
   
   
   主要对以下几个方面做了优化:
   
   1、面向对象的设计优化
   
   - interfaceName,  methodName,  group,  version 这个四元组,出现频率高且共同使用,可以使用对象代替
   - DefaultMetricsCollector 和 MetricsStatComposite 
两个类都有发布MetricsEvent的行为,MetricsStatComposite定位数据聚合载体,应该只负责内部数据的处理,事件注册和发布应该由单独的类来管理(参考spring),类职责分离可以更容易扩展和防止单类代码膨胀。
   
   2、内存使用的优化
   
   -    
MetricsFilter里的方法(invoke,onResponse,onError)每次触发,会new临时对象MetricsCollectExecutor,这是没必要的,改成statc方法可以减少yong
 gc次数。
   - 另外,使用了简单的对象池,来获取前面的四元组对象
   
   3、一些重复代码的优化
   
   
   
   


-- 
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: notifications-unsubscr...@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to