This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 1d3d77bb261 Add : add description for @HighFrequencyInvocation in code 
of conduct (#30333)
1d3d77bb261 is described below

commit 1d3d77bb261e3c3a88215ed6bf1f70da9a3a3c58
Author: 孙念君 Nianjun Sun <[email protected]>
AuthorDate: Thu Feb 29 00:35:03 2024 +0800

    Add : add description for @HighFrequencyInvocation in code of conduct 
(#30333)
    
    * Add : add description for @HighFrequencyInvocation in code of conduct
    
    * Add : add canBeCached description
    
    * Format : format the document
    
    * Add : add more content
    
    * Format : format the description
    
    * Refactor : remove useless invoker
    
    * Add : add the english version of HighFrequencyInvocation usage
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
    
    * Refactor : refactor the description
---
 docs/community/content/involved/conduct/code.cn.md | 10 +++++++++-
 docs/community/content/involved/conduct/code.en.md | 12 ++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/docs/community/content/involved/conduct/code.cn.md 
b/docs/community/content/involved/conduct/code.cn.md
index d195dbd5cf4..b85b7e13cd9 100644
--- a/docs/community/content/involved/conduct/code.cn.md
+++ b/docs/community/content/involved/conduct/code.cn.md
@@ -24,7 +24,7 @@ chapter = true
  - 应尽量将设计精细化拆分;做到小幅度修改,多次数提交,但应保证提交的完整性。
  - 通过 Spotless 统一代码风格,执行 `./mvnw spotless:apply -Pcheck` 格式化代码。
  - 如果您使用 IDEA,可导入推荐的 `src/resources/code-style-idea.xml`。
- 
+
 ## 编码规范
 
  - 使用 linux 换行符。
@@ -64,6 +64,14 @@ chapter = true
  - 使用具体的 `@SuppressWarnings("xxx")` 代替 `@SuppressWarnings("all")`。
  - 热点方法内应避免使用 Java Stream,除非该场景下使用 Stream 的性能优于普通循环。
  - 工具类名称命名为 `xxUtils`。
+ - 合理使用 `@HighFrequencyInvocation` 注解,用于聚焦关键方法性能的优化。
+   - 使用 `@HighFrequencyInvocation` 注解的时机:
+     - 请求频繁调用的链路,标注其中高频调用的类、方法或构造器,标注范围精确匹配;
+     - `canBeCached` 属性为 `true` 时,表示该目标为可复用的缓存资源,例如:数据库连接。
+   - 标注 `@HighFrequencyInvocation` 的代码段须严格保证代码性能,以下为标注代码段内的禁止项:
+     - 禁止调用 Java Stream API;
+     - 禁止通过 `+` 连接字符串;
+     - 禁止调用 LinkedList 的 `get(int index)` 方法。
 
 ## 单元测试规范
 
diff --git a/docs/community/content/involved/conduct/code.en.md 
b/docs/community/content/involved/conduct/code.en.md
index 546cc97c630..92e165e1b21 100644
--- a/docs/community/content/involved/conduct/code.en.md
+++ b/docs/community/content/involved/conduct/code.en.md
@@ -1,5 +1,5 @@
 +++
-title = "Code of Conduct" 
+title = "Code of Conduct"
 weight = 2
 chapter = true
 +++
@@ -38,7 +38,7 @@ The following code of conduct is based on full compliance 
with [ASF CODE OF COND
    - A variable composed of abbreviation should use lower camel case: 
mysqlAuthenticationMethod, sqlStatement, mysqlConfig.
  - Except return an input parameter as result, returning variable should be 
named with `result`; Variables in the loop structure are named with `each`; 
Replace `each` with `entry` in map.
  - Exceptions when catch are named with `ex`; Exceptions when catch but do 
nothing are named with `ignored`.
- - Name property files with `Spinal Case`(a variant of `Snake Case` which uses 
hyphens `-` to separate words). 
+ - Name property files with `Spinal Case`(a variant of `Snake Case` which uses 
hyphens `-` to separate words).
  - Split codes that need to add notes with it into small methods, which are 
explained with method names.
  - Have constants on the left and variable on the right in `=` and `equals` 
conditional expressions; Have variable on the left and constants on the right 
in `greater than` and `less than` conditional expressions.
  - Beside using same names as input parameters and global fields in assign 
statement, avoid using `this` modifier.
@@ -61,6 +61,14 @@ The following code of conduct is based on full compliance 
with [ASF CODE OF COND
  - Use concentrate `@SuppressWarnings("xxx")` instead of 
`@SuppressWarnings("all")`.
  - Avoid using Java Stream in hot methods, unless the performance of using 
Stream is better than using loop in that situation.
  - Utility class should be named in the form of `xxUtils`.
+ - Reasonably use the @HighFrequencyInvocation annotation to focus on 
optimizing the performance of critical methods.
+   - Occasions for using the @HighFrequencyInvocation annotation:
+     - In frequently invoked requests, add annotation to classes, methods, or 
constructors with high frequency calls; precise matching within the scope of 
annotation;
+     - The `canBeCached` attribute being set as true indicates that the target 
is a reusable cached resource. For example: a database connection.
+   - Code segments with annotation @HighFrequencyInvocation must strictly 
guarantee code performance. The following are prohibited code segments within:
+     - It is prohibited to call Java Stream API;
+     - It is prohibited to concat String using "+";
+     - It is prohibited to call LinkedList's get(int index) method.
 
 ## Contributor Covenant Unit Test of Conduct
 

Reply via email to