Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type:optimize] Optimize BodyParamUtils with Caffeine cache #5905

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

g0ne150
Copy link
Contributor

@g0ne150 g0ne150 commented Jan 20, 2025

  • Added Caffeine cache for base type checking
  • Improved isBaseType() performance with 5000-entry cache
  • Reduced class loading overhead

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

image

Description (英文)

This PR addresses the performance issue observed in the isBaseType method. During performance testing with the shenyu-examples-apache-dubbo-service project, using the dubbo/insert API on a Linux environment (8 CPU, 32GB memory), the isBaseType method was identified as a bottleneck through flame graph analysis.

By introducing a caching mechanism to isBaseType, the TPS (transactions per second) significantly improved from ~1500 to ~18000 during testing with ab. This optimization greatly enhances system performance for scenarios involving frequent type checks.

Description (中文)

本 PR 优化了 isBaseType 方法的性能问题。通过火焰图分析,在使用 shenyu-examples-apache-dubbo-service 项目对 dubbo/insert 接口进行性能测试时(Linux 环境,8 核 CPU,32GB 内存),发现 isBaseType 方法存在性能瓶颈。

isBaseType 增加缓存机制后,在使用 ab 工具进行测试时,TPS 从约 1500 提升至约 18000。这一优化大幅提升了频繁类型检查场景下的系统性能。

ab 命令: ab -c 300 -n 10000 -T application/json -p body.json http://localhost:9195/dubbo/insert

image

image

Changes (变更内容)

  1. Add a caching mechanism to the isBaseType method to reduce redundant computations.

Test Cases (测试情况)

  • Conducted performance tests using shenyu-examples-apache-dubbo-service and ab tool, confirming the performance improvement.

Impact (影响范围)

  • Performance: Significant TPS improvement in scenarios involving frequent type checks.
  • Compatibility: No breaking changes; the caching mechanism is seamlessly integrated.

g0ne150 and others added 5 commits January 20, 2025 10:11
@yu199195
Copy link
Member

hi,very good job, can you add my wechat :xixy199195, i will add you to shenyu contributor group

@yu199195 yu199195 added this to the 2.7.1 milestone Jan 21, 2025
@yu199195 yu199195 merged commit 8f3a1d0 into apache:master Jan 21, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants