memstat 0.1.1 → 0.1.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 +4 -4
- data/.travis.yml +8 -0
- data/README.md +6 -7
- data/lib/memstat/oob_gc/unicorn.rb +6 -3
- data/lib/memstat/version.rb +1 -1
- data/test/test_memstat.rb +6 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecbb34062ad5ab1f96df42d10a8a76914786b7a
|
4
|
+
data.tar.gz: 2eb1e6ac83385e2acffee47e5241ed2d763d8ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00ec8d94f9596b90e6d2b10d90c35ef713dd73e44530acec3ab765d23a71514fdfa6ca12c0bf24944451753fcc910722c6e0169eb15efa6a6fb2b885da7ad07f
|
7
|
+
data.tar.gz: b89d256ee555f1804fb9a66ae0a48ddeb374901c402871ec49fca735d04eaa0aac969abf21d1eb6ac2440d23df144777017ae85347823d124d891bc915a00078
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Memstat: Fast memory statistics & better out-of-band GC
|
2
2
|
|
3
|
+
[](http://travis-ci.org/kenn/memstat)
|
4
|
+
|
3
5
|
Ruby 2.1 introduced generational garbage collection. It is a major improvement in terms of shorter GC pauses and overall higher throughput, but that comes with a [drawback of potential memory bloat](http://www.omniref.com/blog/blog/2014/03/27/ruby-garbage-collection-still-not-ready-for-production/).
|
4
6
|
|
5
7
|
You can mitigate the bloat by manually running `GC.start`, but like Unicorn's out-of-band GC, doing it after every request can seriously hurt the performance. You want to run `GC.start` only when the process gets larger than X MB.
|
@@ -79,7 +81,7 @@ status.swap # Swap size
|
|
79
81
|
|
80
82
|
See [details](http://ewx.livejournal.com/579283.html) for each item.
|
81
83
|
|
82
|
-
##
|
84
|
+
## Command Line
|
83
85
|
|
84
86
|
memstat also comes with a command line utility to report detailed memory statistics by aggregating `/proc/[pid]/smaps`.
|
85
87
|
|
@@ -111,10 +113,7 @@ In this case, 103,536 kB out of 131,020 kB is shared, which means 79% of its mem
|
|
111
113
|
|
112
114
|
For more details, [read this gist](https://gist.github.com/kenn/5105175).
|
113
115
|
|
114
|
-
##
|
116
|
+
## Changelog
|
115
117
|
|
116
|
-
1.
|
117
|
-
|
118
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
119
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
120
|
-
5. Create new Pull Request
|
118
|
+
### 0.1.0, release 2014-04-03
|
119
|
+
* Initial release
|
@@ -8,10 +8,13 @@ module Memstat
|
|
8
8
|
|
9
9
|
def process_client(client)
|
10
10
|
super(client) # Unicorn::HttpServer#process_client
|
11
|
-
status = Memstat::Proc::Status.new(:pid => Process.pid)
|
12
11
|
|
13
|
-
if
|
14
|
-
|
12
|
+
if Memstat.linux?
|
13
|
+
status = Memstat::Proc::Status.new(:pid => Process.pid)
|
14
|
+
|
15
|
+
if status.rss > OOBGC_THRESHOLD
|
16
|
+
GC.start
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/memstat/version.rb
CHANGED
data/test/test_memstat.rb
CHANGED
@@ -42,11 +42,15 @@ class TestCli < Minitest::Test
|
|
42
42
|
assert_equal status.swap, 0 * 1024
|
43
43
|
end
|
44
44
|
|
45
|
+
def test_oobgc
|
46
|
+
Memstat::OobGC::Unicorn
|
47
|
+
end
|
48
|
+
|
45
49
|
def test_benchmark
|
46
50
|
n = 100
|
47
51
|
Benchmark.bm(10) do |x|
|
48
|
-
x.report("ps:") { n.times.each { `ps -o rss -p #{Process.pid}`.strip.
|
49
|
-
x.report("memstat:") { n.times.each { Memstat::Proc::Status.new(:
|
52
|
+
x.report("ps:") { n.times.each { `ps -o rss -p #{Process.pid}`.strip.to_i } }
|
53
|
+
x.report("memstat:") { n.times.each { Memstat::Proc::Status.new(:path => STATUS_PATH).rss } }
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|