halo/application
guqing eb969122ff
perf: add caching for extension getter to enhance performance (#7102)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为扩展获取增加缓存以提高网站整体性能

在此之前,每个请求都要经过很多过滤器,而一些过滤器会获取扩展因此导致频繁查询扩展和扩展点定义拖慢了速度

**测试情况**

初始化一个全新环境,安装并启用以下插件和主题
- 已激活主题: [Earth 1.11.0](https://github.com/halo-dev/theme-earth)
- 已启动插件:
  - [SEO 工具集 1.0.1](https://github.com/f2ccloud/plugin-seo-tools)
  - [OAuth2 认证 1.5.0](https://github.com/halo-sigs/plugin-oauth2)
  - [Trailing Slash 1.0.0](https://github.com/halo-sigs/plugin-trailing-slash)
  - [评论组件 2.5.1](https://github.com/halo-dev/plugin-comment-widget)
  - [KaTeX 2.1.0](https://github.com/halo-sigs/plugin-katex)
  - [应用市场 1.9.0](https://www.halo.run/store/apps/app-VYJbF)

通过 Apache Benchmark (ab) 进行 1w 次请求并发 100 个,测试访问首页,得到以下测试结果:

核心指标对比

|指标|改进前|改进后|提升情况|
|---|---|---|---|
|**总耗时 (Time taken)**|27.030 秒|25.718 秒|减少约 **4.9%**|
|**每秒请求数 (RPS)**|369.96 req/sec|388.83 req/sec|提升约 **5.1%**|
|**单请求平均耗时**|270.298 ms|257.181 ms|减少约 **4.9%**|
|**传输速率 (Transfer Rate)**|6346.44 KB/s|6670.12 KB/s|提升约 **5.1%**|

综合分析
- 性能提升主要体现在:请求处理时间(Processing)、等待时间(Waiting)以及每秒请求数(RPS)均有 约5% 左右的提升。
- 传输效率更高:通过更快的处理时间,传输速率提高了 5.1%。
- 长尾请求优化显著:最大响应时间减少了约 14.9%,意味着极端情况下的性能更优。

#### Does this PR introduce a user-facing change?

```release-note
为扩展获取增加缓存使网站整体性能提升 5% 以上
```
2024-12-04 02:41:09 +00:00
..
src perf: add caching for extension getter to enhance performance (#7102) 2024-12-04 02:41:09 +00:00
build.gradle chore: bump preset plugins version (#7024) 2024-11-12 06:35:20 +08:00