[PR #27549] improve: speed up tracing config decryption process #31801

Closed
opened 2026-02-21 20:50:10 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/27549

State: closed
Merged: Yes


Summary

Closes #27547
This PR optimizes tracing config decryption performance in OpsTraceManager by implementing batch decryption and LRU caching for decrypted configurations. The changes reduce cryptographic overhead and eliminate redundant decryption operations for identical tracing configs.

Key Changes:

  • Batch Decryption: Replaced individual decrypt_token() calls with batch_decrypt_token() for improved efficiency
  • LRU Cache: Added decrypted_configs_cache to cache decrypted tracing configurations

Screenshots

Benchmark

image

Traces

Before

image

After

image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/27549 **State:** closed **Merged:** Yes --- ## Summary Closes #27547 This PR optimizes tracing config decryption performance in `OpsTraceManager` by implementing batch decryption and LRU caching for decrypted configurations. The changes reduce cryptographic overhead and eliminate redundant decryption operations for identical tracing configs. ### Key Changes: - **Batch Decryption**: Replaced individual `decrypt_token()` calls with `batch_decrypt_token()` for improved efficiency - **LRU Cache**: Added `decrypted_configs_cache` to cache decrypted tracing configurations ## Screenshots ### Benchmark <img width="1338" height="308" alt="image" src="https://github.com/user-attachments/assets/74140017-577e-4d89-8cdb-3214f4f696b6" /> ### Traces #### Before <img width="1372" height="715" alt="image" src="https://github.com/user-attachments/assets/db1302e2-5a42-4b1f-8c54-4f5b6d0530b5" /> #### After <img width="1920" height="919" alt="image" src="https://github.com/user-attachments/assets/75d86817-f69b-4975-a086-e5525afa8be8" /> ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [ ] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:50:10 -05:00
yindo closed this issue 2026-02-21 20:50:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31801