Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-88562

Create a linked-list container with a small element optimization

    • Service Arch
    • Fully Compatible
    • v8.0
    • Service Arch 2024-04-01, Service Arch 2024-04-15, Service Arch 2024-04-29
    • 0

      We have a few std::list usages where the most common case is a single element. In the most common case, we're heap-allocating and freeing a single element, which is wasteful. Similar to absl::InlinedVector, we can make a linked-list-like container where the first node is allocated inline with the container, making the first node free. All future elements will just default to heap-allocation.

      This would benefit perf in two hot code paths:

      Both of these linked lists are most commonly of size 1 and in the hot path of every operation. I observed about a 500ns speedup in the TransactionResources path, so I would expect about a 1 microsecond speedup by changing both, assuming we can't find others.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: