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

(FACT-3149) Fix memory usage reporting on FreeBSD #2523

Merged
merged 1 commit into from
Nov 4, 2023

Conversation

smortex
Copy link
Contributor

@smortex smortex commented Sep 16, 2022

  • In vmstat(8), "free memory" correspond to unused memory that does not
    contain any data, and does not include cache / inactive memory which
    has some data but is immediatly available to the system if memory is
    needed.
    Prefer to get active and wired memory page count form sysctl(3) which
    correpond to the used memory that can (active) and cannot (wired) be
    swapped out, and multiply these by the size of a memory page. This
    give a better overview of the current memory usage.
  • Prefer vm.stats.vm.v_page_count over hw.physmem: The available
    memory can be lower that what is physically present in the system and
    the free / used memory is a portion of the usable memory more than a
    portion of the physical memory.

Description of the sysctl entries:

  • vm.stats.vm.v_page_count: Total number of pages in system
  • vm.stats.vm.v_active_count: Active pages
  • vm.stats.vm.v_wire_count: Wired pages
  • vm.stats.vm.v_page_size: Page size in bytes

@smortex smortex requested a review from a team as a code owner September 16, 2022 23:56
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@smortex smortex force-pushed the freebsd-available-memory branch from a0b8214 to 09d2886 Compare December 31, 2022 21:11
@smortex
Copy link
Contributor Author

smortex commented Dec 31, 2022

Rebased to fix conflicts
Edit 2022-01-05: Rebased to fix CI
Edit 2022-01-06: Rebased to re-trigger new CI tests with Ruby 3.2

@smortex smortex force-pushed the freebsd-available-memory branch 2 times, most recently from e584555 to 5bb267e Compare January 6, 2023 19:26
@CLAassistant
Copy link

CLAassistant commented Apr 19, 2023

CLA assistant check
All committers have signed the CLA.

@joshcooper
Copy link
Contributor

@smortex sorry for the delay, could you rebase on main?

@smortex smortex force-pushed the freebsd-available-memory branch from 5bb267e to 173009d Compare September 16, 2023 03:09
@smortex
Copy link
Contributor Author

smortex commented Sep 16, 2023

@joshcooper rebased without conflict and CI is green!

@smortex smortex force-pushed the freebsd-available-memory branch from 173009d to fd03e81 Compare September 25, 2023 17:56
@smortex
Copy link
Contributor Author

smortex commented Sep 25, 2023

I saw new required tests with jruby, so rebased on top of main to trigger a new run.

@smortex smortex force-pushed the freebsd-available-memory branch from fd03e81 to fc8e661 Compare October 6, 2023 07:27
* In vmstat(8), "free memory" correspond to unused memory that does not
  contain any data, and does not include cache / inactive memory which
  has some data but is immediatly available to the system if memory is
  needed.
  Prefer to get active and wired memory page count form sysctl(3) which
  correpond to the used memory that can (active) and cannot (wired) be
  swapped out, and multiply these by the size of a memory page.  This
  give a better overview of the current memory usage.
* Prefer `vm.stats.vm.v_page_count` over `hw.physmem`:  The available
  memory can be lower that what is physically present in the system and
  the free / used memory is a portion of the usable memory more than a
  portion of the physical memory.
@smortex smortex force-pushed the freebsd-available-memory branch from fc8e661 to 392cc65 Compare November 2, 2023 15:12
@joshcooper
Copy link
Contributor

Thank you @smortex!

@joshcooper joshcooper merged commit e5eb025 into puppetlabs:main Nov 4, 2023
18 checks passed
@smortex smortex deleted the freebsd-available-memory branch November 4, 2023 09:37
@joshcooper joshcooper added the bug Something isn't working label Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants