Perf: cache regex pattern and result, optimize string concatenation (#7199)
The possible metrics names are relatively fixed in an OAP run, we previously always escape the metrics names, building a new regex Pattern from scratch, which is cpu-consuming. In this patch, I cache the escaped metrics names, and if it missed, use a pre-compiled regex Pattern to escape the metrics name. This patch also replace string concatenation `+` with `StringBuilder` in generated classes, which won't get optimized by Java compiler This may reduce 1~1.5 vCPU under 20K RPS environment.
Showing
想要评论请 注册 或 登录