posix-spawn 0.3.13 → 0.3.14
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 +5 -5
- data/.travis.yml +9 -0
- data/bin/posix-spawn-benchmark +116 -16
- data/ext/posix-spawn.c +6 -1
- data/lib/posix/spawn/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 01e020a90230d321090d2a78ed58f6679b35d11f1a889e1ea4290a6e01ad6ca3
|
4
|
+
data.tar.gz: 60a60a31086a398a9a5c17de2488cf3f4020aadf7f3bbe94a3a558a42404129e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a2c99b5f08c59fb83c53f244e4395336a0aa5ddfc900a4a16ed57f038135ad3384efc6869afd6d4ec06964ecf4f13008db25cd6cb578dff8bfd7bdf5da04ae
|
7
|
+
data.tar.gz: d4ab86a82d93d18de72263d21c3702e7a13eb1b6df27543cc9589429b49ff9046df9018fe6ed08a60ff1ba0ac28e5d1967ad27f4ecb60e4af25830ea89c9ce52
|
data/.travis.yml
ADDED
data/bin/posix-spawn-benchmark
CHANGED
@@ -1,17 +1,117 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
#/ Usage: posix-spawn-benchmark [-n <count>] [-m <mem-size>]
|
3
|
+
#/ Run posix-spawn (Ruby extension) benchmarks and report to standard output.
|
4
|
+
#/
|
5
|
+
#/ Options:
|
6
|
+
#/ -n, --count=NUM total number of processes to spawn.
|
7
|
+
#/ -m, --mem-size=MB RES size to bloat to before performing benchmarks.
|
8
|
+
#/ -g, --graph benchmark at 10MB itervals up to RES and graph results.
|
9
|
+
#/
|
10
|
+
#/ Benchmarks run with -n 1000 -m 100 by default.
|
11
|
+
require 'optparse'
|
12
|
+
require 'posix-spawn'
|
13
|
+
require 'benchmark'
|
14
|
+
include Benchmark
|
15
|
+
|
16
|
+
allocate = 100 * (1024 ** 2)
|
17
|
+
iterations = 1_000
|
18
|
+
graphmode = false
|
19
|
+
ARGV.options do |o|
|
20
|
+
o.set_summary_indent(' ')
|
21
|
+
o.on("-n", "--count=num") { |val| iterations = val.to_i }
|
22
|
+
o.on("-m", "--mem-size=MB") { |val| allocate = val.to_i * (1024 ** 2) }
|
23
|
+
o.on("-g", "--graph") { graphmode = true }
|
24
|
+
o.on_tail("-h", "--help") { exec "grep ^#/ <'#{__FILE__}' |cut -c4-" }
|
25
|
+
o.parse!
|
26
|
+
end
|
27
|
+
|
28
|
+
if graphmode
|
29
|
+
bloat = []
|
30
|
+
data = {}
|
31
|
+
chunk = allocate / 10
|
32
|
+
max = 0
|
33
|
+
|
34
|
+
10.times do
|
35
|
+
puts "allocating #{chunk / (1024 ** 2)}MB (#{(bloat.size+1) * chunk / (1024 ** 2)}MB total)"
|
36
|
+
bloat << ('x' * chunk)
|
37
|
+
# size = bloat.size / (1024 ** 2)
|
38
|
+
|
39
|
+
%w[ fspawn pspawn ].each do |type|
|
40
|
+
print " - benchmarking #{type}... "
|
41
|
+
time = Benchmark.realtime do
|
42
|
+
iterations.times do
|
43
|
+
pid = POSIX::Spawn.send(type, 'true')
|
44
|
+
Process.wait(pid)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
puts "done (#{time})"
|
48
|
+
|
49
|
+
data[type] ||= []
|
50
|
+
data[type] << time
|
51
|
+
max = time if time > max
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
max = max < 0.5 ? (max * 10).round / 10.0 : max.ceil
|
56
|
+
minmb, maxmb = chunk/(1024**2), allocate/(1024**2)
|
57
|
+
series = %w[ fspawn pspawn ].map{|name| data[name].map{|d| "%.2f" % d }.join(',') }
|
58
|
+
|
59
|
+
chart = {
|
60
|
+
:chs => '900x200',
|
61
|
+
:cht => 'bvg', # grouped vertical bar chart
|
62
|
+
:chtt => "posix-spawn-benchmark --graph --count #{iterations} --mem-size #{maxmb} (#{RUBY_PLATFORM})",
|
63
|
+
|
64
|
+
:chf => 'bg,s,f8f8f8', # background
|
65
|
+
:chbh => 'a,5,25', # 25px between bar groups
|
66
|
+
|
67
|
+
:chd => "t:#{series.join('|')}", # data
|
68
|
+
:chds => "0,#{max}", # scale
|
69
|
+
:chdl => 'fspawn (fork+exec)|pspawn (posix_spawn)', # legend
|
70
|
+
:chco => '1f77b4,ff7f0e', # colors
|
71
|
+
|
72
|
+
:chxt => 'x,y',
|
73
|
+
:chxr => "1,0,#{max},#{max/5}", # y labels up to max time
|
74
|
+
:chxs => '1N** secs', # y labels are +=' secs'
|
75
|
+
:chxl => "0:|#{minmb.step(maxmb, maxmb/10).map{ |mb| "#{mb} MB"}.join('|')}", # x bucket labels
|
76
|
+
}
|
77
|
+
|
78
|
+
url = "https://chart.googleapis.com/chart?"
|
79
|
+
url += chart.map do |key, val|
|
80
|
+
"#{key}=#{val.gsub(' ','%20').gsub('(','%28').gsub(')','%29').gsub('+','%2B')}"
|
81
|
+
end.join('&')
|
82
|
+
url += '#.png'
|
83
|
+
|
84
|
+
puts url
|
85
|
+
|
86
|
+
exit!
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "benchmarking fork/exec vs. posix_spawn over #{iterations} runs" +
|
90
|
+
" at #{allocate / (1024 ** 2)}M res"
|
91
|
+
|
92
|
+
# bloat the process
|
93
|
+
bloat = 'x' * allocate
|
94
|
+
|
95
|
+
# run the benchmarks
|
96
|
+
bm 40 do |x|
|
97
|
+
x.report("fspawn (fork/exec):") do
|
98
|
+
iterations.times do
|
99
|
+
pid = POSIX::Spawn.fspawn('true')
|
100
|
+
Process.wait(pid)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
x.report("pspawn (posix_spawn):") do
|
104
|
+
iterations.times do
|
105
|
+
pid = POSIX::Spawn.pspawn('true')
|
106
|
+
Process.wait(pid)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
if Process.respond_to?(:spawn)
|
110
|
+
x.report("spawn (native):") do
|
111
|
+
iterations.times do
|
112
|
+
pid = Process.spawn('true')
|
113
|
+
Process.wait(pid)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/ext/posix-spawn.c
CHANGED
@@ -61,7 +61,7 @@ posixspawn_obj_to_fd(VALUE obj)
|
|
61
61
|
* rb_fix2int takes care of raising if the provided object is a
|
62
62
|
* Bignum and is out of range of an int
|
63
63
|
*/
|
64
|
-
fd = (
|
64
|
+
fd = FIX2INT(obj);
|
65
65
|
break;
|
66
66
|
|
67
67
|
case T_SYMBOL:
|
@@ -283,6 +283,11 @@ each_env_i(VALUE key, VALUE val, VALUE arg)
|
|
283
283
|
const char *ev = envp[i];
|
284
284
|
|
285
285
|
if (strlen(ev) > name_len && !memcmp(ev, name, name_len) && ev[name_len] == '=') {
|
286
|
+
/* This operates on a duplicated environment -- release the
|
287
|
+
* existing entry memory before shifting the subsequent entry
|
288
|
+
* pointers down. */
|
289
|
+
free(envp[i]);
|
290
|
+
|
286
291
|
for (j = i; envp[j]; ++j)
|
287
292
|
envp[j] = envp[j + 1];
|
288
293
|
continue;
|
data/lib/posix/spawn/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: posix-spawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -52,6 +52,7 @@ extra_rdoc_files:
|
|
52
52
|
- HACKING
|
53
53
|
files:
|
54
54
|
- ".gitignore"
|
55
|
+
- ".travis.yml"
|
55
56
|
- COPYING
|
56
57
|
- Gemfile
|
57
58
|
- HACKING
|
@@ -91,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.5.2
|
95
|
+
rubygems_version: 3.0.3
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: posix_spawnp(2) for ruby
|