Multi-threaded Object Memory Management via Thread Affinity

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In multi-threaded systems, existing memory management techniques lead to cache contention, excessive memory usage, and inefficient memory allocation and deallocation, particularly when objects are allocated on one thread and freed on another, resulting in suboptimal cache efficiency and scalability issues.

Innovation Solution

The implementation of a memory caching system using shared thread affinity caches, where objects are returned to their originating thread's free-list, and a method to manage local and remote free-lists dynamically, ensuring objects are recycled back to their home thread, thereby reducing cache misses and memory wastage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If per-thread free-lists are used to improve memory allocation speed, then allocation speed is improved, but cache contention and false sharing increase when multiple threads access the same memory

Engineering Contradiction:
Improvememory allocation speedVSAvoidcache contention
Core Design Contradiction:
SpeedVSObject-affected harmful factors

Solution Approach 1:

The system segments memory management by creating per-thread free-lists that are localized to each thread's cache. This segmentation allows threads to allocate and free memory without competing for the same cache lines, eliminating false sharing and cache contention while maintaining high allocation speed.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Each thread is assigned its own local free-list stored in thread-local memory or cache. This local quality ensures that memory allocation operations are performed on locally cached data rather than shared memory, improving both speed and reducing cache coherence traffic.

Inventive Principle:
Principle #3Local quality

2Adaptability or versatility

If objects are allocated on one thread and freed on another thread, then thread cooperation and memory sharing are improved, but memory migration across CPU cores increases reducing cache efficiency

Engineering Contradiction:
Improvethread cooperationVSAvoidcache efficiency
Core Design Contradiction:
Adaptability or versatilityVSLoss of energy

Solution Approach 1:

The system introduces a thread-affinity mechanism as an intermediary that tracks the original allocating thread for each memory object. When a thread frees memory, the system uses this affinity information to redirect the free operation back to the home thread's free-list, preventing memory migration and maintaining cache locality.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system implements feedback by storing thread-affinity metadata with each allocated object. This feedback mechanism allows the memory manager to make informed decisions about where to place freed objects, ensuring they return to their originating thread's cache rather than being lost to another thread's free-list.

Inventive Principle:
Principle #23Feedback

3Speed

If per-thread free-lists cache memory for reuse, then allocation speed is improved, but excessive memory is held and not available for operating system re-use

Engineering Contradiction:
Improveallocation speedVSAvoidmemory usage
Core Design Contradiction:
SpeedVSQuantity of substance

Solution Approach 1:

The system implements dynamic memory management where per-thread free-lists are not fixed in size but adapt based on allocation patterns. The memory manager can dynamically adjust the amount of memory retained in thread-local free-lists versus returning to the system, optimizing the balance between allocation speed and system memory availability.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The system implements a hierarchical memory retention strategy where memory is discarded from per-thread free-lists under certain conditions (e.g., when thresholds are exceeded or after prolonged idle periods) and recovered by the operating system. This prevents excessive memory hoarding while maintaining sufficient cache for high-speed allocation.

Inventive Principle:
Principle #34Discarding and recovering

4Quantity of substance

If traditional memory allocators use global allocation strategies, then memory is available for all threads, but lock contention reduces scalability

Engineering Contradiction:
Improvememory availabilityVSAvoidscalability
Core Design Contradiction:
Quantity of substanceVSProductivity

Solution Approach 1:

The system segments the global memory pool into per-thread free-lists, allowing each thread to independently manage its own memory cache. This segmentation eliminates the need for global locks during allocation and free operations, as threads operate on their own localized data structures, thereby improving scalability to many threads.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The per-thread free-list mechanism serves multiple functions: it acts as a local cache for fast allocation, a queue for deferred freeing operations, and a mechanism for tracking thread affinity. This multi-functionality replaces the need for complex global allocation strategies while maintaining memory availability.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS9400692B2System and method for managing the allocating and freeing of objects in a multi-threaded system
Publication Date: 2016.07.26 SOFTWARE AG
  • US9400692B2 patent drawing
  • US9400692B2 patent drawing
  • US9400692B2 patent drawing

AI summary

A memory management system for managing objects which represent memory in a multi-threaded operating system extracts the ID of the home free-list from the object header to determine whether the object is remote and adds the object to a remote object list if the object is determined to be remote. The memory management system determines whether the number of objects on the remote object list exceeds a threshold. If the threshold is exceeded, the system batch-removes the objects on the remote object list and then adds those objects to the appropriate one or more remote home free-lists.