Skip to content

rfc: A storage engine for synth responses #4344

@nigoroll

Description

@nigoroll

Context: This proposal partly replaces #4341, but has been written to stand on its own.

The basic steps for generating synthetic response bodies from vcl_synth{} currently are (as of 033d1d4):

Via this code path, we end up making two copies of the arguments to VRT_l_xyz_body(). There is a similar code path to handle vcl_backend_error {}, which differs in that the second copy is to a stevedore object which potentially can be longer lived (represent a "synthetic cache object"), and is likely to outlive the scope of the backend request.

So there is optimization potential here to save two (for vcl_synth{}) and one (for vcl_backend_error{}) copies of the body data, respectively.

To optimize both cases, I propose to do the following:

  • collect the VRT_l_xyz_body() arguments in arrays of io vectors. The required data structure has already been proposed as VSCARAB in Prepare Varnish-Cache for the age of AI #4209
  • For vcl_backend_error{}, copy the io vectors to the storage object, basically identical to now, but saving one copy
  • For vcl_synth{}, implement a trivial stv_synth stevedore, which takes the arrays of io vectors via a private interface and later "outputs" them via the object iterator callback.

The proposed stv_synth is safe because, all arguments ever passed to VRT_l_xyz_body() have at least PRIV_TASK lifetime (see also #4269 for a similar optimization based on the same insight).

The net effect of this proposal, if implemented, is to save two memory copy operations for body data created in vcl_synth{} and save one memory copy operation for body data created in vcl_backend_error{}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions