github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/spanlatch/doc.go (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  /*
    12  Package spanlatch provides a latch management structure for serializing access
    13  to keys and key ranges. Latch acquisitions affecting keys or key ranges must wait
    14  on already-acquired latches which overlap their key range to be released.
    15  
    16  The evolution of complexity can best be understood as a series of incremental
    17  changes, each in the name of increased lock granularity to reduce contention and
    18  enable more concurrency between requests. The structure can trace its lineage
    19  back to a simple sync.Mutex. From there, the structure evolved through the
    20  following progression:
    21  
    22      * The structure began by enforcing strict mutual exclusion for access to any
    23        keys. Conceptually, it was a sync.Mutex.
    24      * Concurrent read-only access to keys and key ranges was permitted. Read and
    25        writes were serialized with each other, writes were serialized with each other,
    26        but no ordering was enforced between reads. Conceptually, the structure became
    27        a sync.RWMutex.
    28      * The structure became key range-aware and concurrent access to non-overlapping
    29        key ranges was permitted. Conceptually, the structure became an interval
    30        tree of sync.RWMutexes.
    31      * The structure became timestamp-aware and concurrent access of non-causal
    32        read and write pairs was permitted. The effect of this was that reads no
    33        longer waited for writes at higher timestamps and writes no longer waited
    34        for reads at lower timestamps. Conceptually, the structure became an interval
    35        tree of timestamp-aware sync.RWMutexes.
    36  
    37  */
    38  package spanlatch