runger_stripmem 0.1.3 → 1.0.0

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: 430f19c2b873b35dc070599a1ebc89e379fd2586b6004b6ad881b150f25ecb65
4
- data.tar.gz: 2cb094e74c2e6975fc197e9feb7f5f5c7db34439ceec201493f8aeabf14e70f8
3
+ metadata.gz: 245daf784fb56991d0a51737d0dfdccfc091f690f9bede4da82ad34c83e5f746
4
+ data.tar.gz: a1a6e09ea2af7fe6922329a5c444a8199d52b5b28cb95d94f0cd2a3d6df2ab60
5
5
  SHA512:
6
- metadata.gz: 7fb73b2e9fbfd477a96093e92e0fc1516e3b42e73748c9212ab8024d878b80a544aed2d44601d9b25c4ea8ccb89a30f8f2fb12143662da6c03ba972366116eef
7
- data.tar.gz: d4123b00f4b9b87de43203a32edeecf8e341a605818209241fb419ee0899ef992eb6fd537d229e0d601b872b02187b759bef818796e3086c59504f417667a260
6
+ metadata.gz: f5158980ef6193c7a35a84d0e984477493b4239bca187f1f5ef236dab6f02d1942471260b7793310c3f41a630ebabd8b0c5e00e608cd946bfbc59676c1579f8a
7
+ data.tar.gz: 9d86912ac61164199bbf6d828698e9366eddf99ec2a98eae7428e7e1ae21fffb41956f295893ec045f2c7b7153c86513332513bb9e01e041b21f8fcb427efa5a
data/README.md CHANGED
@@ -4,6 +4,10 @@ Show a live chart of your process's memory usage.
4
4
 
5
5
  ![example](https://f.cloud.github.com/assets/20158/812189/e4b87038-eeeb-11e2-9ead-f4c4e6b5b589.png)
6
6
 
7
+ ## ⚠️ Linux only ⚠️
8
+
9
+ `runger_stripmem` reads process memory information directly from `/proc/<pid>/status` (specifically the `RssAnon` and `VmSwap` fields). These interfaces and fields are provided by the Linux kernel and do not exist on other operating systems (macOS, Windows, BSD, etc.). Because the gem depends on this Linux-specific memory accounting, `runger_stripmem` only works on Linux.
10
+
7
11
  ## Installation
8
12
 
9
13
  To use `runger_stripmem` standalone, install it:
data/lib/strip_mem/app.rb CHANGED
@@ -82,15 +82,20 @@ class StripMem::App
82
82
 
83
83
  def ps(channel)
84
84
  ps =
85
- `ps -o pid=,rss= -p #{processes.keys.join(',')}`.lines.each_with_object({}) do |line, h|
86
- pid, rss = line.strip.split(/\s+/) ; h[Integer(pid, 10)] = Integer(rss, 10)
85
+ processes.keys.each_with_object({}) do |pid, h|
86
+ status = File.read("/proc/#{pid}/status")
87
+ anon = Integer(status[/^RssAnon:\s+(\d+)/, 1], 10) # kB (preferred)
88
+ swap = Integer(status[/^VmSwap:\s+(\d+)/, 1], 10) # kB
89
+ h[pid] = anon + swap
90
+ rescue Errno::ENOENT, Errno::EACCES
91
+ # process already gone or we lack permission
87
92
  end
93
+
88
94
  offset = Time.now - start_time
89
95
  channel.push(
90
96
  offset:,
91
-
92
97
  samples: processes.map do |pid, name|
93
- { name: "[#{pid}] #{name}", rss: ps[pid] }
98
+ { name: "[#{pid}] #{name}", anon_plus_swap: ps[pid] }
94
99
  end,
95
100
  )
96
101
  end
@@ -159,8 +159,8 @@ $(function() {
159
159
  lastOffset = data.offset;
160
160
  if (!chart)
161
161
  chart = charts[sample.name] = new StripChart(d3.select('body'), sample.name);
162
- if (sample.rss)
163
- chart.addPoint({x: data.offset, y: sample.rss});
162
+ if (sample.anon_plus_swap)
163
+ chart.addPoint({x: data.offset, y: sample.anon_plus_swap});
164
164
  }
165
165
  };
166
166
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StripMem
4
- VERSION = '0.1.3'
4
+ VERSION = '1.0.0'
5
5
  end
data/lib/strip_mem/web.rb CHANGED
@@ -9,7 +9,7 @@ class StripMem::Web
9
9
 
10
10
  def run!
11
11
  puts('Starting a server on http://localhost:9999/')
12
- App.run!(port: 9999, server: 'puma') do
12
+ App.run!(port: 9999, server: 'puma', server_settings: { config_files: ['-'] }) do
13
13
  system('open http://localhost:9999/')
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runger_stripmem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Burke