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

[Performance] Rewrite the thread_safe cache. #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DarkSharpness
Copy link
Collaborator

@DarkSharpness DarkSharpness commented Nov 16, 2024

  1. Add a cpp test on cache efficiency and correctness
  2. Refactor the thread_safe_cache.

In the new thread_safe_cache, we maintain only 1 unified mapping instead of 2. In addition, in our implementation, we acquire the unique_lock less, which may bring a significant improvement in efficiency in some cases.

Here's the result for TEST(XGrammarParallelTest, CacheEfficiency) on my machine AMD EPYC 7R32.

End to end time (preprocessing time 2s not included):

  • Old cache: 1152ms
  • New cache: 217ms

gcc version: 13.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant