Hi all,

I'd like to introduce a change to an existing API that leads to a new
function signature and add two new related convenience functions that
enable plugins. This change enables control of buffer sizes and
watermarks used with IOBuffers between the plugin and the core, which
is implemented through the PluginVC interface. Tuning these parameters
can have a marked improvement on plugin performance in some use cases
due to more consistent flow of data and less pressure on the ATS event
system in general.

The API changes are here: https://github.com/apache/trafficserver/pull/8088
Example of plugin modifications leveraging these changes:
https://github.com/apache/trafficserver/pull/8089

Proposal: modify `TSHttpConnectWithPluginId()` to support IOBuffer
sizes via indexes and watermarks.

Existing signature:
tsapi TSVConn TSHttpConnectWithPluginId(struct sockaddr const *addr,
const char *tag, int64_t id)

New/additional signature:
tsapi TSVConn TSHttpConnectPlugin(struct sockaddr const *addr, const
char *tag, int64_t id, int64_t buffer_index, int64_t
buffer_water_mark)

In order to provide backward compatibility for plugins that do not
wish to specify these additional parameters or plugins that exist
outside of the repository, I have modified the existing function to
call the new function with values that match the current behavior.

The `PluginVCCore::alloc()` and `PluginVCCore::init()` functions were
modified to take these new arguments, and two new overridable
`records.config` parameters were introduced to control the values on a
default and per-remap basis. The defaults for these new parameters
match the existing implicit values of a buffer index of 8 and no
watermark. The new parameters are:

proxy.config.plugin.vc.default_buffer_index
proxy.config.plugin.vc.default_buffer_water_mark

There are at least two ways that an intercept plugin can interact with
IOBuffers through the PluginVC interface; what was just described, and
when the intercept plugin calls `TSHttpTxnIntercept()`. The
`TSHttpTxnIntercept()` function has also been modified to pass these
two new parameters into the PluginVC alloc and init functions.

Because the buffer index and watermark are required to call
`TSHttpConnectPlugin()` and because `TSHttpTxnIntercept()` also needs
these values, I introduced two self-explanatory convenience functions
to quickly get these values:

tsapi TSMgmtInt TSPluginVCGetIOBufferIndex(TSHttpTxn txnp)
tsapi TSMgmtInt TSPluginVCGetIOBufferWaterMark(TSHttpTxn txnp)

Because these settings can and will crash ATS when misconfigured,
logic will cause defaults to be used when out of range values are
detected, but error checking of watermarks is currently limited to
non-negative values as the upper bound depends upon the buffer index.
--
Thanks,
Jeff

Reply via email to