Documentation

LeanPool.OrderMaintenance.Model.Core

Level F: the insert-only core (prototype/core.py) #

Elements → groups → chunks, guarded label writes, group and chunk splits, the reservation process, and FALLBACK.

Allocation #

Append an element with the given group, label and external handle.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Allocate a group in a chunk, reusing the free list when possible.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Chunks are never freed: emptied ones stay as DEAD tombstones until the next rebuild.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Label primitives (guarded) #

        Choose a midpoint label, failing if there is no strictly intermediate integer.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Choose a label one spacing after its predecessor within the given bit width.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Choose a label one positive spacing before its successor.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Queries #

              Read an element’s lexicographic chunk, group and element order labels.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Compare chunk, group and element labels lexicographically.

                Equations
                Instances For

                  Compare the order labels of two element indices.

                  Equations
                  Instances For

                    Mark an element deleted while retaining its linked-list position.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Chunk sizes #

                      Change a chunk’s element count by one and adjust its quiet queue entry.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Element insertion #

                        def OrderMaintenance.Model.linkElem (s : Core) (x y lab h : Nat) :

                        Link a new element y (the next free index) with label lab and handle h right after x, in x's group.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Insert after an element, choosing a guarded label before mutating the list.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Group splits #

                            def OrderMaintenance.Model.linkGroupPair (s : Core) (g gl gr labL labR : Nat) :

                            Link new groups gl (label labL) and gr (label labR) right before and after g, in the group list and in g's chunk, as the overflow siblings of g.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Unlink group g from the group list and from its chunk, and free it.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Move element e, the first of group g, to the end of group gl with label lab.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Move element e, the last of group g, to the front of group gr with label lab.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    A label for a new group right before g in its chunk.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      A label for a new group right after g in its chunk.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

                                        Allocate the overflow siblings and begin incrementally splitting a group.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          Unlink and free group g, which must be alive and empty.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Remove an empty group and release its overflow siblings to the quiet state.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              Move one element of the splitting group g (alive, non-empty) to its lighter sibling. Returns the sibling.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For

                                                One move of a splitting group. Returns false once g is gone.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Perform at most the configured number of steps of a group split.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    Advance the split of a group or of its source if it is an overflow sibling.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For

                                                      Chunk splits #

                                                      The candidate unit at the left/right end of chunk x: the family (gl, g, gr) of a splitting group if the end group is its overflow sibling on that side, else the end group.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        A family unit must lie in chunk x, as consecutive groups (the prototype checked the chunk of all members but the first).

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For

                                                          The groups that one chunk-split move takes from the left/right end of chunk x: a whole family (gl, g, gr) of a splitting group, or one group (invariant F).

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For

                                                            Leave an empty chunk as a tombstone and release its overflow siblings.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For

                                                              Labels for k groups appended after a group labelled prev (none: the receiving chunk is empty; start at the centre).

                                                              Equations
                                                              Instances For

                                                                Labels for k groups prepended before a group labelled nxt, in list order.

                                                                Equations
                                                                Instances For

                                                                  Move the groups u, a prefix of chunk x, to the end of chunk y, with labels labs.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For

                                                                    Move the groups u, a suffix of chunk x, to the front of chunk z, with labels labs.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For

                                                                      Chunk sizes after moving the groups u from x to dst.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        One chunk-split move of chunk x (non-empty) towards its sibling on the left (right): the unit at that end of x moves to the end (front) of the sibling, with guarded labels. Returns the sibling and the unit.

                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For

                                                                          Move one end unit into an overflow sibling, or finish an empty chunk split.

                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For

                                                                            Perform at most the configured number of steps of a chunk split.

                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For

                                                                              Advance the split of a chunk or of its source if it is an overflow sibling.

                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For

                                                                                Reservation #

                                                                                Link new chunks y and z right before and after x in the chunk list.

                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For

                                                                                  The split's bookkeeping: chunk states and siblings, and the running job.

                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For

                                                                                    Split chunk x (just popped from the queue): link two new chunks around it, give them tags (guarded) and start the top structure's insertion job.

                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For

                                                                                      Spend a bounded number of steps on the largest queued chunk and its top-tree job.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For

                                                                                        FALLBACK #

                                                                                        The element list, from the sentinel.

                                                                                        Equations
                                                                                        Instances For

                                                                                          FALLBACK's layout, in closed form: the element list cut into groups of ⌊G/2⌋, the groups cut into chunks of ⌊⌊T/2⌋/⌊G/2⌋⌋; group k (0-based) gets index k + 1 and lies in chunk ⌊k / gpc⌋ + 1; labels are evenly spaced at every level.

                                                                                          The target number of elements per group during a fallback rebuild.

                                                                                          Equations
                                                                                          Instances For

                                                                                            The target number of groups per chunk during a fallback rebuild.

                                                                                            Equations
                                                                                            Instances For

                                                                                              The number of groups in FALLBACK's chunk c (0-based), out of m.

                                                                                              Equations
                                                                                              Instances For

                                                                                                The number of chunks for m groups.

                                                                                                Equations
                                                                                                Instances For

                                                                                                  Construct one group record for the fallback partition of the element list.

                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For

                                                                                                    Construct one chunk record for the fallback partition into groups.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For

                                                                                                      Element i of group k gets group k + 1 and label (i + 1)·step.

                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For

                                                                                                        The state after FALLBACK's layout (tags are set by relabelAll).

                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For

                                                                                                          Synchronous rebuild of groups, chunks and tags from the element list.

                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          Instances For

                                                                                                            Insertion with background work #

                                                                                                            Update sizes and spend the scheduled group, chunk and reservation work after insertion.

                                                                                                            Equations
                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                            Instances For
                                                                                                              def OrderMaintenance.Model.onGuard {α : Type} (act handler : CM α) :
                                                                                                              CM α

                                                                                                              Run act; on a failed guard run handler from the state reached (bugs propagate).

                                                                                                              Equations
                                                                                                              Instances For

                                                                                                                Insert an element and run background work, rebuilding after recoverable guard failures.

                                                                                                                Equations
                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                Instances For

                                                                                                                  Construction #

                                                                                                                  A fresh core's lists: one chunk, one group, and the sentinel element (dead), all index 1.

                                                                                                                  Equations
                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                  Instances For

                                                                                                                    The top structure of a fresh core: built now, or with lazy later, one prepareStep at a time.

                                                                                                                    Equations
                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                    Instances For

                                                                                                                      One step of deferred initialization; true once the core is ready.

                                                                                                                      Equations
                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                      Instances For