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

Partial support for Cache-Control's no-cache directive #4073

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Commits on Oct 14, 2024

  1. Configuration menu
    Copy the full SHA
    8ab9fe7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a00388f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4abb6b9 View commit details
    Browse the repository at this point in the history
  4. vtc: Use proper ETags in r2422

    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    a30c134 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    195732e View commit details
    Browse the repository at this point in the history
  6. hash: Skip the unbusy ceremony for private objects

    This reduces a great deal of spurious activity on the private_oh waiting
    list and removes unncessary conditionals when dealing with cacheable (or
    at least searchable) objects.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    1698349 View commit details
    Browse the repository at this point in the history
  7. hash: Only grant OC_F_BUSY to lookup-able objects

    The OC_F_BUSY flag is used to decide whether to disembark a request into
    an objhead's waiting list. Therefore, it makes sense to only give this
    flag to objcores for which the outcome may be a shareable object.
    
    This excludes synthetic and private (req.body and passed req) objcores,
    and objects inserted with HSH_Insert(). Inserted objects are never busy
    since they come already ready to use.
    
    Pass transactions don't need this flag either. The OC_F_BUSY flag was
    somewhat conflated with struct busyobj in the fetch state machine. We
    don't need OC_F_BUSY to convey that a fetch task is coordinated with a
    req task, oc->boc is already doing that. The OC_F_BUSY|OC_F_PRIVATE bits
    should be considered an oxymoron since OC_F_BUSY drives waiting list
    activity and OC_F_PRIVATE is for objects that are not shareable by
    definition.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    50e5880 View commit details
    Browse the repository at this point in the history
  8. hash: Make HSH_Fail() rush the waiting list

    This is not a nice caching outcome. In fact, when a fetch fails we don't
    know the outcome. In that case we need to rush one request that will
    trigger a new fetch and hopefully complete with a proper outcome to rush
    other requests accordingly.
    
    As far as lookup is concerned there is no point in keeping the OC_F_BUSY
    flag so in the case where a failure happens before a proper HSH_Unbusy()
    it can be dropped before the rush. This would otherwise happen once the
    last objcore reference is dropped. One is held by the current fetch task
    and the other one by the client task that triggerred the fetch. It would
    amount to an unnecessary delay.
    
    The OC_F_FAILED flag will prevent it from being looked up, so there is
    no reason to delay the rush until the final objcore reference is dropped.
    
    This also means that once the client task that triggered the fetch task
    resumes it can only be operating on a non-busy object.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    2a8d4dd View commit details
    Browse the repository at this point in the history
  9. obj: Rush objcores based state changes

    The BOS_PREP_STREAM state is retired. It was used as a stop-gap to
    "unbusy" objects before waking up the client task for good. Instead,
    the HSH_Unbusy() and HSH_Fail() functions are called once the gap is
    closed, depending on the outcome.
    
    This removes one unnecessary signal and consolidates multiple call
    sites, ensuring that objects always drop the OC_F_BUSY flag from a
    central location, for fetch tasks.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    c0739ff View commit details
    Browse the repository at this point in the history
  10. hash: Trigger a rush when an objcore is withdrawn

    This is the counterpart of HSH_Unbusy() for the cases where the req task
    will not schedule a fetch task, at which point we know we can already
    wake up a request, if there is one on the waiting list.
    
    This encapsulates the "wake up only one request" semantic using a new
    OC_F_WITHDRAWN flag. Although this flag is not being used yet, it will
    when the state of the objcore determines the rush policy instead of the
    call site.
    
    When a bgfetch is withdrawn, the extra rush becomes redundant with the
    policy rush on the hit objcore. There will eventually be no more rush
    for the hit objcore, which will remove the redundancy just introduced.
    
    In order to withdraw objcores in a single critical section, a function
    HSH_DerefObjCoreUnlock() is added.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    bf049ca View commit details
    Browse the repository at this point in the history
  11. hash: Dropping an objcore does not rush the waiting list

    Rushing the waiting list because an objcore was dropped was a source
    of spurious wakeups, including the case where the dropped objcore is not
    even relevant to the objhead waiting list. It is now guaranteed that an
    object either dropped its OC_F_BUSY flag once ready (otherwise failed or
    withdrawn) or never had this flag to begin with for objcores that can't
    be looked up.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    88921b4 View commit details
    Browse the repository at this point in the history
  12. hash: Operate waiting list rush on objcores

    Operating on an objcore allows to preserve the different rush strategies
    that existed so far:
    
    - rush one request for failed fetch tasks
    - rush one request for withdrawn objects
    - rush rush_exponent requests otherwise
    
    For the cases where no rush is expected, a null objcore is passed.
    
    For cacheable objects, all waiters are temporarily woken up at once,
    until waiting list matches are handled separately.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    7364a76 View commit details
    Browse the repository at this point in the history
  13. hash: Retire HSH_RUSH_POLICY

    From now on, the policy will be derived from the objcore.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    2828d53 View commit details
    Browse the repository at this point in the history
  14. hash: Treat a waiting list match as a revalidation

    If a fetch succeeded and an object was inserted as cacheable, it means
    that the VCL did not interpret the backend response as revalidated and
    shareable with other clients on the waiting list.
    
    After changing the rush to operate based on objcore flags instead of
    the call site deciding how many clients to wake up, the same objcore
    reference is now passed to requests before they reembark a worker. This
    way when an objcore is already present during lookup we can attempt a
    cache hit directly on the objcore that triggered the rush, removing a
    degree of uncertainty in the waiting list behavior.
    
    Instead of repurposing the req::hash_objhead field into an equivalent
    req::hash_objcore, the field is actually removed. In order to signal
    that a request comes back from its waiting list, the life time of the
    req::waitinglist flag is extended until cnt_lookup() is reentered. But
    to avoid infinite rush loops when a return(restart) is involved, the
    flag is turned into a req::waitinglist_gen counter to prevent objcore
    rushes from affecting requests entering the waiting list after they
    began for a given objcore.
    
    If the rushed objcore matches a request, the lookup can result in a
    hit without entering the regular lookup critical section. The objhead
    lock is briefly acquired to release req's reference on the objhead, to
    rely solely on the objcore's objhead reference like a normal hit, and
    generally perform hit-related operations. This change brings back the
    exponential rush of cacheable objects briefly neutered.
    
    This shifts the infamous waiting list serialization phenomenon to the
    vary header match. Since most spurious rushes at every corner of objhead
    activity are gone, this change puts all the spurious activity on the
    incompatible variants alone instead of all objects on more occasions.
    
    If a cacheable object was inserted in the cache, but already expired,
    this behavior enables cache hits. This can be common with multi-tier
    Varnish setups where one Varnish server may serve a graced object to
    another, but true of any origin server that may serve stale yet valid
    responses.
    
    The waiting list enables a proper response-wide no-cache behavior from
    now on, but the built-in VCL prevents it by default. This is also the
    first step towards implementing no-cache and private support at the
    header field granularity.
    
    fgen
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    cd28daa View commit details
    Browse the repository at this point in the history
  15. fetch: Retire waiting list safety net

    If a synthetic beresp is inserted into the cache with no TTL, grace or
    keep at all, it is now considered validated (although not in the best
    circumstances) and will be passed to all requests in the waiting list.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    7e4bc71 View commit details
    Browse the repository at this point in the history
  16. SQUASHME: prune rush policy remnant

    It appeared long after the original patch series and in the absence of a
    merge conflict I didn't check whether it still built locally.
    
    To be squashed in the "hash: Retire HSH_RUSH_POLICY" commit.
    dridi committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    1dd77c2 View commit details
    Browse the repository at this point in the history