-
Notifications
You must be signed in to change notification settings - Fork 846
Automatic caching of parsed STRING config values #12735
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
Conversation
src/api/InkAPI.cc
Outdated
| auto &parsed = ParsedConfigCache::lookup(conf, std::string_view(value, length)); | ||
| s->t_state.my_txn_conf().negative_caching_list = parsed.status_code_list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ParsedConfigCache::lookup are the high level view of where the value of this patch happens. Instead of calling the conversion logic for each of these "complex" strings (like the negative caching status list, in this example) every transaction, this parsed value retrieval is called through an interface that caches the results so that the compution is only done once.
This introduces ParsedConfigCache in HttpConfig to automatically cache parsed results for STRING configs that require expensive parsing. When TSHttpTxnConfigStringSet() is called for configs like negative_caching_list, insert_forwarded, server_session_sharing.match, negative_revalidating_list, or host_res_data (ip_resolve), the parsing now happens once per unique value and is cached for subsequent calls. This optimization is transparent to plugins - they call TSHttpTxnConfigStringSet() as usual and automatically benefit from the caching. Fixes: apache#12292
4df9b0c to
6beaff4
Compare
masaori335
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems better than other approaches, because we don't need to change TS APIs.
This introduces ParsedConfigCache in HttpConfig to automatically cache parsed results for STRING configs that require expensive parsing. When TSHttpTxnConfigStringSet() is called for configs like negative_caching_list, insert_forwarded, server_session_sharing.match, negative_revalidating_list, or host_res_data (ip_resolve), the parsing now happens once per unique value and is cached for subsequent calls. This optimization is transparent to plugins - they call TSHttpTxnConfigStringSet() as usual and automatically benefit from the caching.
Fixes: #12292