trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Make negative_caching_list/negative_revalidating_list overridable

Open masaori335 opened this issue 7 months ago • 1 comments

Alternative approach of #12206 to override HTTP Status Code list in the config.

PR #12206 has a overhead because the per-remap configuration list was stored as a string and parsed on every transactions. This PR avoids that cost by parsing the string once at config-load time by introducing new TS APIs.

New TS APIs Proposal

TS_RECORDDATATYPE_VARIANT
using TSConfigValue = std::variant<HttpStatusCodeList *>;

TSReturnCode TSHttpTxnConfigParse(TSConfigValue &dst, TSOverridableConfigKey key, const char *value, size_t length);
TSReturnCode TSHttpTxnConfigSet(TSHttpTxn txnp, TSOverridableConfigKey key, const TSConfigValue &src);

TSHttpTxnConfigParse parses given string into appropriate data structure and stores it in a TSConfigValue. It's a variant of data structures. TSHttpTxnConfigSet set the parsed TSConfigValue to the transaction to override a variable.

TSConfigValue is a std::variant for type safety and future extension.

Usage

The changes in conf_remap illustrate how to use the new APIs.

  1. (Re)loading config: Parse the config string into HttpStatusCodeList * by TSHttpTxnConfigParse and store it in the TSConfigValue
  2. Remap: Override the variable by TSHttpTxnConfigSet

Out of scope

The HttpStatusBitSet container could be replaced by std::unordered_set or similar to reduce memory usage, but that refactoring is intentionally left for a future PR.

masaori335 avatar Jun 12 '25 06:06 masaori335

After talked with @zwoop, this is trying to combine current type specific set APIs into one TSHttpTxnConfigSet.

masaori335 avatar Jun 13 '25 07:06 masaori335

This is getting big change, so let me divide into 2 steps.

1). Make negative_caching_list/negative_revalidating_list overridable with MgmtConverter 2). Fix overhead of MgmtConverter by introducing new TS APIs.

masaori335 avatar Jun 20 '25 06:06 masaori335

This pull request has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

github-actions[bot] avatar Sep 21 '25 02:09 github-actions[bot]