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]: JSONLogitsProcessor repeats the same build_regex_from_schema again and again #8383

Open
stas00 opened this issue Sep 11, 2024 · 0 comments
Labels
performance Performance-related issues

Comments

@stas00
Copy link
Contributor

stas00 commented Sep 11, 2024

Proposal to improve performance

Why does the regex get recompiled on every request? the object gets instantiated for every request and the regex is rebuilt even though most of the time the schema is likely to remain the same.

regex_string = build_regex_from_schema(schema_str, whitespace_pattern)

probably @lru_cache should do the trick here? does it work on object constructors? or would it be cleaner to add a wrapper around build_regex_from_schema and cache that?

This is otherwise similar to #8308?

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

No branches or pull requests

1 participant