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

[pull] master from netdata:master #290

Merged
merged 1 commit into from
Jan 12, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 12, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Enhancements:

  • Optimize element allocation in the ARAL allocator to reduce contention and improve throughput.

* fast path to quickly allocate elements on a new page

* partitions on aral incoming lock
@pull pull bot added the ⤵️ pull label Jan 12, 2025
Copy link

sourcery-ai bot commented Jan 12, 2025

Reviewer's Guide by Sourcery

This pull request introduces a per-CPU free list to the ARAL allocator, aiming to reduce contention on the global free list lock. This is achieved by partitioning the incoming free list and using a bitmap to track available partitions. The change also includes a fast path for allocating new elements, using atomic operations to avoid locking when possible.

Sequence diagram for optimized memory allocation

sequenceDiagram
    participant C as Client
    participant A as ARAL Allocator
    participant P as ARAL Page

    C->>A: Request memory allocation
    A->>P: Try fast path allocation
    alt Fast path successful
        P-->>A: Return new segment
        A-->>C: Return memory
    else Fast path failed
        P->>P: Lock available list
        P->>P: Check incoming partitions
        P->>P: Get free slot from partition
        P-->>A: Return reused memory
        A-->>C: Return memory
    end
Loading

Class diagram showing ARAL page structure changes

classDiagram
    class ARAL_PAGE {
        +const char* filename
        +uint8_t* data
        +bool marked
        +bool started_marked
        +bool mapped
        +uint32_t size
        +uint32_t max_elements
        +uint64_t elements_segmented
        +uint32_t incoming_partition_bitmap
    }
    note for ARAL_PAGE "Changed structure layout and added partitioned incoming list"

    class ARAL_FREE {
        +size_t size
        +ARAL_FREE* next
    }

    ARAL_PAGE --> ARAL_FREE : has multiple incoming[4]
Loading

State diagram for ARAL memory allocation states

stateDiagram-v2
    [*] --> TryFastPath
    TryFastPath --> NewSegment: Slot < max_elements
    TryFastPath --> CheckAvailable: Slot >= max_elements
    CheckAvailable --> LockPartition: No available list
    CheckAvailable --> ReuseMemory: Has available list
    LockPartition --> ReuseMemory: Get from partition
    NewSegment --> [*]: Return memory
    ReuseMemory --> [*]: Return memory
Loading

File-Level Changes

Change Details Files
Introduced per-CPU free lists to reduce lock contention.
  • Partitioned the incoming free list into ARAL_PAGE_INCOMING_PARTITIONS separate lists.
  • Added a bitmap (incoming_partition_bitmap) to track available partitions.
  • Modified aral_add_free_slot___no_lock_required to add free slots to a partition based on the current thread ID.
  • Modified aral_get_free_slot___no_lock_required to check for available partitions and retrieve free slots from them.
  • Added a fast path in aral_get_free_slot___no_lock_required to allocate new elements using atomic operations, avoiding locking when possible if the page isn't full
src/libnetdata/aral/aral.c
Added a fast path for allocating new elements using atomic operations.
  • Added elements_segmented to ARAL_PAGE to track the number of elements allocated using the fast path.
  • Modified aral_get_free_slot___no_lock_required to use elements_segmented for allocating new elements without locking when possible if the page isn't full
src/libnetdata/aral/aral.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pull pull bot merged commit 0232abd into webfutureiorepo:master Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant