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 #365

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Feb 14, 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:

  • Improve memory allocation of onewayalloc buffers by using nd_mmap_advanced and falling back to mallocz if it fails. Also, use nd_munmap to free memory allocated with nd_mmap_advanced and freez for memory allocated with mallocz

@pull pull bot added the ⤵️ pull label Feb 14, 2025
@pull pull bot merged commit 7c986c5 into webfutureiorepo:master Feb 14, 2025
Copy link

sourcery-ai bot commented Feb 14, 2025

Reviewer's Guide by Sourcery

The pull request modifies the onewayalloc library to use mmap for memory allocation, with a fallback to malloc if mmap fails. It also updates the deallocation logic to use munmap or free based on the allocation method.

Sequence diagram for onewayalloc_create_internal

sequenceDiagram
  participant OWA as Oneway Allocator
  participant MMAP as nd_mmap_advanced
  participant MALLOC as mallocz

  OWA->MMAP: Allocate memory using mmap
  MMAP-->>OWA: Returns memory or NULL
  alt mmap fails
    OWA->MALLOC: Allocate memory using malloc
    MALLOC-->>OWA: Returns memory
    OWA->OWA: Set page->mmap = false
  else mmap succeeds
    OWA->OWA: Set page->mmap = true
  end
  OWA-->>OWA: Returns page
Loading

Sequence diagram for onewayalloc_destroy

sequenceDiagram
  participant OWA as Oneway Allocator
  participant MUNMAP as nd_munmap
  participant FREE as freez

  OWA->OWA: Iterate through pages
  alt page->mmap is true
    OWA->MUNMAP: Deallocate memory using munmap
    MUNMAP-->>OWA: Returns
  else page->mmap is false
    OWA->FREE: Deallocate memory using free
    FREE-->>OWA: Returns
  end
Loading

File-Level Changes

Change Details Files
Modified the onewayalloc to use mmap for memory allocation, falling back to malloc if mmap fails.
  • Introduced a mmap boolean to the OWA_PAGE struct to track whether mmap was used for allocation.
  • Attempt to allocate memory using nd_mmap_advanced in onewayalloc_create_internal. If this fails, fall back to mallocz.
  • Set the mmap flag accordingly based on whether mmap or mallocz was used.
  • Modified onewayalloc_destroy to use nd_munmap if mmap was used, otherwise use freez.
src/libnetdata/onewayalloc/onewayalloc.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

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