process-metrics 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb30f9e1ffed610ad4a6735a8875f6438eae603ce53e6cb67274e7f893f1c4d5
4
- data.tar.gz: 0474ced532e19377ee8b4b7003c21d1a098afc8df5fb3f9865ea163aa756eced
3
+ metadata.gz: 213edfd5fbe960b9a75ac7574f17828f6b9f24ec5328ebf8c6ee85dcafeae0c2
4
+ data.tar.gz: 8daf591b9691f058dbe87dd861c0d8ff2e2669edff94b098ad0de36440963b14
5
5
  SHA512:
6
- metadata.gz: 898911e287967bb88596747da31bc6e956bdf4aa8bdea23b461df7998922155d72bd577ca0092320514aa41738547576abd379779a89cf66a22d5a63f0e279f8
7
- data.tar.gz: 0f78a3b25a090f9823feae392358281e10f1828a0cb4d324ad880a0a877e0ae34d8cd9d4fbedf7018fe847b5dff1b2f2c6a27702eebb61d714afb46faf4eda7a
6
+ metadata.gz: 7cfafb180bf9286f5eb35dd2d5393b77ca88fc86f8b93509aed2f30870255dbba5e617ceceb69c17607bc3e620b7599e8c11ab960323033a97087a2acc45340c
7
+ data.tar.gz: 78427458c5dd06674690a1fe3ffab4d1c85a6ce265defce5dc2191be874ee995c87299c86de9b83e88e84318425ca2b16361e69df4b9d26d4badca1dbb8078e7
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,12 +8,12 @@ module Process
8
8
  # Per-host (system-wide) memory metrics. Use Host::Memory for total/used/free and swap; use Process::Metrics::Memory for per-process metrics.
9
9
  module Host
10
10
  # Struct for host memory snapshot. All sizes in bytes.
11
- # @attribute total [Integer] Total memory (cgroup limit when in a container, else physical RAM).
12
- # @attribute used [Integer] Memory in use (total - free).
13
- # @attribute free [Integer] Available memory (MemAvailable-style: free + reclaimable).
14
- # @attribute swap_total [Integer, nil] Total swap, or nil if not available.
15
- # @attribute swap_used [Integer, nil] Swap in use, or nil if not available.
16
- Memory = Struct.new(:total, :used, :free, :swap_total, :swap_used) do
11
+ # @attribute total_size [Integer] Total memory (cgroup limit when in a container, else physical RAM).
12
+ # @attribute used_size [Integer] Memory in use (total_size - free_size).
13
+ # @attribute free_size [Integer] Available memory (MemAvailable-style: free + reclaimable).
14
+ # @attribute swap_total_size [Integer, nil] Total swap, or nil if not available.
15
+ # @attribute swap_used_size [Integer, nil] Swap in use, or nil if not available.
16
+ Memory = Struct.new(:total_size, :used_size, :free_size, :swap_total_size, :swap_used_size) do
17
17
  alias as_json to_h
18
18
 
19
19
  def to_json(*arguments)
@@ -23,11 +23,30 @@ module Process
23
23
  self.resident_size + self.swap_size
24
24
  end
25
25
 
26
- # The unique set size, the size of completely private (unshared) data.
27
- def unique_size
26
+ # The private set size, the size of completely private (unshared) data.
27
+ # This is the sum of Private_Clean and Private_Dirty pages.
28
+ # @returns [Integer] Total private memory in bytes.
29
+ def private_size
28
30
  self.private_clean_size + self.private_dirty_size
29
31
  end
30
32
 
33
+ # The private set size is also known as the unique set size.
34
+ alias unique_size private_size
35
+
36
+ # The total size of shared (potentially shared with other processes) memory.
37
+ # This is the sum of Shared_Clean and Shared_Dirty pages.
38
+ #
39
+ # When tracking Copy-on-Write (CoW) activity in forked processes:
40
+ # - Initially, most memory is shared between parent and child.
41
+ # - As the child writes to memory, CoW triggers and shared pages become private.
42
+ # - Tracking shared_size decrease vs unique_size increase can indicate CoW activity.
43
+ # - If shared_size decreases by X and unique_size increases by ~X, it's likely CoW.
44
+ #
45
+ # @returns [Integer] Total shared memory in bytes.
46
+ def shared_size
47
+ self.shared_clean_size + self.shared_dirty_size
48
+ end
49
+
31
50
  # Create a zero-initialized Memory instance.
32
51
  # @returns [Memory] A new Memory object with all fields set to zero.
33
52
  def self.zero
@@ -37,7 +56,7 @@ module Process
37
56
  # Total system/host memory in bytes. Delegates to Host::Memory.capture.
38
57
  # @returns [Integer | Nil]
39
58
  def self.total_size
40
- Host::Memory.capture&.total
59
+ Host::Memory.capture&.total_size
41
60
  end
42
61
 
43
62
  # Whether the memory usage can be captured on this system.
@@ -7,6 +7,6 @@
7
7
  module Process
8
8
  # @namespace
9
9
  module Metrics
10
- VERSION = "0.10.0"
10
+ VERSION = "0.10.2"
11
11
  end
12
12
  end
data/readme.md CHANGED
@@ -16,9 +16,17 @@ Please see the [project documentation](https://socketry.github.io/process-metric
16
16
 
17
17
  Please see the [project releases](https://socketry.github.io/process-metrics/releases/index) for all releases.
18
18
 
19
+ ### v0.10.2
20
+
21
+ - Add `Process::Metrics::Memory#private_size` for the sum of private (unshared) pages (Private\_Clean + Private\_Dirty); `#unique_size` is now an alias for `#private_size`.
22
+
23
+ ### v0.10.1
24
+
25
+ - Consistent use of `_size` suffix.
26
+
19
27
  ### v0.10.0
20
28
 
21
- - **Host::Memory**: New per-host struct `Process::Metrics::Host::Memory` with `total`, `used`, `free`, `swap_total`, `swap_used` (all bytes). Use `Host::Memory.capture` to get a snapshot; `.supported?` indicates platform support.
29
+ - **Host::Memory**: New per-host struct `Process::Metrics::Host::Memory` with `total_size`, `used_size`, `free_size`, `swap_total_size`, `swap_used_size` (all bytes). Use `Host::Memory.capture` to get a snapshot; `.supported?` indicates platform support.
22
30
 
23
31
  ### v0.9.0
24
32
 
@@ -54,23 +62,6 @@ Please see the [project releases](https://socketry.github.io/process-metrics/rel
54
62
  - Improved support for proportional memory usage (PSS).
55
63
  - Exposed total system memory information.
56
64
 
57
- ### v0.4.0
58
-
59
- - Fixed command formatting in output display.
60
- - Modernized codebase to use current Ruby conventions.
61
- - Improved Darwin (macOS) support with better platform-specific handling.
62
-
63
- ### v0.3.0
64
-
65
- - Added support for `smaps_rollup` on Linux for more efficient memory statistics collection.
66
- - Fixed `smaps_rollup` detection (corrected file path).
67
- - Removed `sz` metric (not supported on Darwin).
68
- - Expanded test coverage.
69
- - Improved documentation with better syntax highlighting and fixed links.
70
- - Avoided abbreviations in naming conventions for better code clarity.
71
- - Added missing dependencies: `bake-test-external` and `json` gem.
72
- - Added summary lines for PSS (Proportional Set Size) and USS (Unique Set Size).
73
-
74
65
  ## Contributing
75
66
 
76
67
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Releases
2
2
 
3
+ ## v0.10.2
4
+
5
+ - Add `Process::Metrics::Memory#private_size` for the sum of private (unshared) pages (Private\_Clean + Private\_Dirty); `#unique_size` is now an alias for `#private_size`.
6
+
7
+ ## v0.10.1
8
+
9
+ - Consistent use of `_size` suffix.
10
+
3
11
  ## v0.10.0
4
12
 
5
- - **Host::Memory**: New per-host struct `Process::Metrics::Host::Memory` with `total`, `used`, `free`, `swap_total`, `swap_used` (all bytes). Use `Host::Memory.capture` to get a snapshot; `.supported?` indicates platform support.
13
+ - **Host::Memory**: New per-host struct `Process::Metrics::Host::Memory` with `total_size`, `used_size`, `free_size`, `swap_total_size`, `swap_used_size` (all bytes). Use `Host::Memory.capture` to get a snapshot; `.supported?` indicates platform support.
6
14
 
7
15
  ## v0.9.0
8
16
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file