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

hash: Transfer waiting list ownership to the objcore #3992

Closed
wants to merge 14 commits into from

Commits on Oct 2, 2023

  1. vtc: Polish c{97..99} tests

    dridi committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    5f24fae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    da96634 View commit details
    Browse the repository at this point in the history
  3. hash: Move enum lookup_e to cache_objhead.h

    It has nothing to do with the hash lookup implementation, this is the
    outcome of a cache lookup.
    dridi committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    acfab77 View commit details
    Browse the repository at this point in the history
  4. hash: Track the most recent busy objcore for lookups

    This is a prerequisite before moving waiting list ownership from objhead
    to objcore.
    dridi committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    84fda34 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2023

  1. hash: Refine the objhead lookup result

    Adding expired variants of miss and hitmiss outcomes will enable better
    code organization, mainly the extraction of the objhead lookup step into
    its own function.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    6673373 View commit details
    Browse the repository at this point in the history
  2. hash: Extract objhead lookup from HSH_Lookup()

    This creates a separate objhead lookup after the hash lookup, and a
    central location to process the objhead lookup result. This makes both
    the lookup code and the lookup result processing code more compact and
    easier to follow individually. In particular, the objhead lookup now
    operates entirely under the objhead lock and has a much better signal
    to noise ratio.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    ebfc019 View commit details
    Browse the repository at this point in the history
  3. hash: Transfer waiting list ownership to the objcore

    The advantages of the objhead owning the waiting list are that we need
    less waiting list heads as they are shared across multiple objcores, we
    get more frequent opportunities to rush waiting requests, and we avoid
    one expensive part of the lookup, which is to find an objhead from a
    request hash.
    
    The downsides are the requirement to always perform a new lookup, which
    increases contention on the objhead lock, and prevents expired but valid
    objects to be considered fresh. This is another way to describe the
    cache-control no-cache directive: a response considered fresh at fetch
    time, but immediately stale afterwards.
    
    Having the waiting list on the objcore means that we reenter the cache
    lookup with the object candidate from the previous lookup, so we may
    short-circuit the more expensive objhead lookup when the objcore is
    compatible with the request rushing off the waiting list. The expensive
    request hash lookup is still avoided, just like before, the objcore has
    a reference to the objhead.
    
    This creates a new first step in the lookup process:
    
    - rush match (when coming from the waiting list)
    - hash lookup (unless coming from the waiting list)
    - objhead lookup (unless there was a rush hit)
    
    This moves the infamous waiting list serialization phenomenon to the
    vary header match. Knowing that a rushed object is guaranteed to lead to
    a cache hit allows the rush policy to be applied wholesale, instead of
    exponentially. Only requests incompatible with the objcore vary header
    may reenter the waiting list, a scenario no different from the spurious
    rush wakeups when operating on the objhead.
    
    The waiting list operations are still guarded by the objhead lock. As it
    stands currently, the exponential rush is indirectly systematic, since
    the unusable objcore is rushed before the objhead lookup.
    
    This is the first step towards implementing no-cache and private support
    at the header field granularity.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    5ce6a48 View commit details
    Browse the repository at this point in the history
  4. hash: No rush for synthetic insertions

    Now that objcores own their waiting lists, they can no longer have
    anything waiting for them at creation time.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    1ba1a20 View commit details
    Browse the repository at this point in the history
  5. hash: Unconditionally rush the waiting list

    This has the same effect, with slightly less ceremony.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    92b9474 View commit details
    Browse the repository at this point in the history
  6. hash: Delay waiting list reference accounting

    The objcore is officially referenced by a request when it leaves its
    waiting list during a rush. This allows migrating a waiting list from
    one objcore to the next without the need to touch reference counters.
    
    The hash_oc field will still have to be updated. This field must be
    be kept to navigate from a request to its waiting list to implement
    walking away from a waiting list.
    
    Refs varnishcache#3835
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    0f77214 View commit details
    Browse the repository at this point in the history
  7. hash: Log the VXID of requests being rushed

    This is very useful to manually verify the rush_exponent behavior.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    57ab2f8 View commit details
    Browse the repository at this point in the history
  8. hash: Make the exponential rush exponential again

    After the migration of the waiting list to the objcore, the result was
    that each request would rush more requests upon reembarking by dropping
    the waited objcore reference before the objhead lookup.
    
    The reference is now dropped after the objhead lookup, allowing for the
    lookup outcome to be checked, either triggerring a complete rush when
    the object is serviceable (modulus vary match) or moving the waiting
    list to the next busy objcore.
    
    This avoids the spurious wakeups caused by objhead rushes when waiting
    lists were owned by objheads. This is however a missed opportunity when
    there are multiple concurrent busy objcores. This could be alleviated
    by linking busy objcores together but at this point this is already a
    net improvement. The only way to get multiple concurrent busy objcores
    on the same objhead would be through the hash_ignore_busy flag anyway.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    0e005de View commit details
    Browse the repository at this point in the history
  9. hash: Retire the HSH_DerefObjCore(rushmax) argument

    Now that waiting lists are owned by objcores, the rush policy no longer
    needs to leak everywhere. Either all the waiters are rushed at once for
    cacheable objects, or according to rush_exponent.
    dridi committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    05d9052 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    6fe0207 View commit details
    Browse the repository at this point in the history