pwrake 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20590e6007af5bc0c567fe8266a82f40aaeec0bbb853bdd87e180f0f1c53bc31
4
- data.tar.gz: 4ec4760f2428d854019675a2f51e49f791102f7eab6b3141e258cfbc25a8842a
3
+ metadata.gz: 4053be2a3de706030e8ee37157453416b379f22c7751db94d2122b607eec6d3a
4
+ data.tar.gz: c76ad99c55d4ee592522337d66327845d72c239df9cfd8bed294e7d7acdc3e83
5
5
  SHA512:
6
- metadata.gz: 391db5799b9091fbbc0a242f78729fe265087581b6b88dbaf9bf01f188e8d4412c749683075c38dfcea4803589289205f85c42320913727fe51628eb7fdaa2f8
7
- data.tar.gz: fc7a41165bdce7fa685e3d922d5b24f6146524deaa52a31049c459d8fa39430b3948b4d02943ec143014181f2f916e3ab6d06f9596b61c05d397243a02770fe4
6
+ metadata.gz: bc954608b0bf14af8782f27273cc9a802951a31a04c2507ef42255a0855af738c9ab71dc9cc5f6afdde2d8c097b27cc01d606d2cf667b083e270a138e9e5ac4d
7
+ data.tar.gz: 192a8cbc976188d637f74b08cec65054235e156e82ecaa1354a75a2dbdadd91e1c8b14b0d21733f15c0d85d601c15db366f0c91c95d0b4919e25a23b886cdb87
@@ -1,5 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
+ require 'pathname'
3
4
  require 'fiddle'
4
5
 
5
6
  module Gfarm
@@ -153,10 +154,7 @@ module Gfarm
153
154
  end
154
155
 
155
156
  def initialize(path)
156
- while File.symlink?(path)
157
- link = File.readlink(path)
158
- path = File.expand_path(link, File.dirname(path))
159
- end
157
+ path = Pathname.new(path).realpath.to_s
160
158
  @realpath = LibGfarm.realpath_by_gfarm2fs(path)
161
159
  ptr_buf = [0].pack('J')
162
160
  e = LibGfarm.gfs_replica_info_by_name(@realpath,@@flags,ptr_buf)
@@ -180,7 +178,8 @@ module Gfarm
180
178
 
181
179
  end
182
180
 
183
- if $0 == __FILE__
181
+
182
+ def gfwhere_pipe
184
183
 
185
184
  [:PIPE,:TERM,:INT].each do |sig|
186
185
  Signal.trap(sig, "EXIT")
@@ -204,3 +203,5 @@ if $0 == __FILE__
204
203
  end
205
204
 
206
205
  end
206
+
207
+ gfwhere_pipe
data/bin/pwrake CHANGED
@@ -14,6 +14,7 @@ require "pwrake/version"
14
14
  require "pwrake/master/master_application"
15
15
  require "pwrake/task/task_manager"
16
16
  require "pwrake/task/task_algorithm"
17
+ require "pwrake/task/file_task_algorithm"
17
18
  require "pwrake/branch/branch_application"
18
19
 
19
20
  class Rake::Application
@@ -25,6 +26,9 @@ class Rake::Task
25
26
  include Pwrake::TaskAlgorithm
26
27
  prepend Pwrake::TaskInvoke
27
28
  end
29
+ class Rake::FileTask
30
+ prepend Pwrake::FileTaskAlgorithm
31
+ end
28
32
 
29
33
  # does NOT exit when writing to broken pipe
30
34
  Signal.trap(:PIPE, "IGNORE")
@@ -17,10 +17,9 @@ module Pwrake
17
17
  else
18
18
  options[:verbose] ||= RakeFileUtils.verbose_flag
19
19
  end
20
- options[:noop] ||= RakeFileUtils.nowrite_flag
20
+ options[:noop] ||= RakeFileUtils.nowrite_flag
21
21
  Rake.rake_check_options options, :noop, :verbose
22
22
  Rake.rake_output_message cmd.join(" ") if options[:verbose]
23
- #Pwrake::Log.stderr_puts cmd.join(" ") if options[:verbose]
24
23
  unless options[:noop]
25
24
  res,status = Pwrake::FileUtils.pwrake_system(*cmd)
26
25
  block.call(res, status)
@@ -41,10 +40,9 @@ module Pwrake
41
40
  else
42
41
  options[:verbose] ||= RakeFileUtils.verbose_flag
43
42
  end
44
- options[:noop] ||= RakeFileUtils.nowrite_flag
43
+ options[:noop] ||= RakeFileUtils.nowrite_flag
45
44
  Rake.rake_check_options options, :noop, :verbose
46
45
  Rake.rake_output_message cmd.join(" ") if options[:verbose]
47
- #Pwrake::Log.stderr_puts cmd.join(" ") if options[:verbose]
48
46
  unless options[:noop]
49
47
  res,status = Pwrake::FileUtils.pwrake_backquote(*cmd)
50
48
  block.call(res, status)
@@ -53,9 +51,6 @@ module Pwrake
53
51
  end
54
52
 
55
53
  def pwrake_system(*cmd)
56
- cmd_log = cmd.join(" ").inspect
57
- #tm = Pwrake::Timer.new("sh",cmd_log)
58
-
59
54
  conn = Pwrake::Shell.current
60
55
  if conn.kind_of?(Pwrake::Shell)
61
56
  res = conn.system(*cmd)
@@ -65,16 +60,11 @@ module Pwrake
65
60
  status = $?
66
61
  status = Rake::PseudoStatus.new(1) if !res && status.nil?
67
62
  end
68
-
69
- #tm.finish("status=%s cmd=%s"%[status.exitstatus,cmd_log])
70
63
  [res,status]
71
64
  end
72
65
 
73
66
  # Pwrake version of backquote command
74
67
  def pwrake_backquote(cmd)
75
- cmd_log = cmd.inspect
76
- #tm = Pwrake::Timer.new("bq",cmd_log)
77
-
78
68
  conn = Pwrake::Shell.current
79
69
  if conn.kind_of?(Pwrake::Shell)
80
70
  res = conn.backquote(*cmd)
@@ -84,8 +74,6 @@ module Pwrake
84
74
  status = $?
85
75
  status = Rake::PseudoStatus.new(1) if status.nil?
86
76
  end
87
-
88
- #tm.finish("status=%s cmd=%s"%[status.exitstatus,cmd_log])
89
77
  [res,status]
90
78
  end
91
79
 
@@ -1,5 +1,7 @@
1
1
  module Pwrake
2
2
 
3
+ class GfwhereError < StandardError; end
4
+
3
5
  class GfarmPostprocess
4
6
 
5
7
  def initialize(selector)
@@ -22,11 +24,11 @@ module Pwrake
22
24
  end
23
25
  s = @reader.get_line
24
26
  if s.nil?
25
- raise "gfwhere: unexpected end"
27
+ raise GfwhereError,"lost connection to gfwhere-pipe"
26
28
  end
27
29
  s.chomp!
28
30
  if s != filename
29
- raise "gfwhere: file=#{filename}, result=#{s}"
31
+ raise GfwhereError,"path mismatch: send=#{filename}, return=#{s}"
30
32
  end
31
33
  while s = @reader.get_line
32
34
  s.chomp!
@@ -223,7 +223,11 @@ module Pwrake
223
223
  end
224
224
  end
225
225
  send_task_to_idle_core
226
- setup_fiber(t)
226
+ if ending?
227
+ @post_pool.finish # need?
228
+ else
229
+ setup_fiber(t)
230
+ end
227
231
  end
228
232
 
229
233
  def setup_fiber(t)
@@ -179,8 +179,10 @@ module Pwrake
179
179
  "[Pw] Show Pwrake configuration options",
180
180
  lambda {|value| options.show_conf = true }
181
181
  ],
182
- ['--report LOGDIR',"[Pw] Generate `report.html' (Report of workflow statistics) in LOGDIR and exit.",
183
- lambda {|value| options.report_dir = value }
182
+ ['--report [LOGDIR]',"[Pw] Generate `report.html' (Report of workflow statistics) in LOGDIR and exit.",
183
+ lambda {|value|
184
+ options.report_dir = value || Dir.pwd
185
+ }
184
186
  ],
185
187
  ['--report-image IMAGE_TYPE',"[Pw] Gnuplot output format (png,jpg,svg etc.) in report.html.",
186
188
  lambda {|value| options.report_image = value }
@@ -172,7 +172,7 @@ module Pwrake
172
172
  'PLOT_PARTITION',
173
173
 
174
174
  ['HOSTFILE','HOSTS'],
175
- ['LOG_DIR','LOG',
175
+ ['LOG_DIR',
176
176
  proc{|v|
177
177
  if v
178
178
  if v == "" || !v.kind_of?(String)
@@ -223,7 +223,7 @@ module Pwrake
223
223
  }],
224
224
  ['NUM_THREADS', proc{|v| v && v.to_i}],
225
225
  ['SHELL_START_INTERVAL', proc{|v| (v || 0.012).to_f}],
226
- ['HEARTBEAT', proc{|v| (v || 240).to_i}],
226
+ ['HEARTBEAT', proc{|v| v && v.to_i}],
227
227
  ['RETRY', proc{|v| (v || 1).to_i}],
228
228
  ['MASTER_HOSTNAME', proc{|v| (v || Socket.gethostname).chomp}],
229
229
  ['WORK_DIR', proc{|v|
@@ -59,59 +59,63 @@ module Pwrake
59
59
  d
60
60
  end
61
61
 
62
- def plot_parallelism(file,fmt)
63
- a = count_start_end_from_csv(file)
62
+
63
+ def plot_parallelism(csvtable, base, fmt)
64
+ a = count_start_end_from_csv_table(csvtable)
64
65
  return if a.size < 4
65
66
 
66
67
  #density = exec_density(a)
67
68
 
68
- base = file.sub(/\.csv$/,"")
69
- fpara = base+"_para.dat"
69
+ fimg = base+'/parallelism.'+fmt
70
70
 
71
71
  n = a.size
72
+ i = 0
72
73
  y = 0
73
74
  y_max = 0
74
75
 
75
- File.open(fpara,"w") do |f|
76
- i = 0
76
+ para = []
77
+ begin
77
78
  t = 0
78
79
  y_pre = 0
79
- begin
80
- while i < n
81
- if a[i][0]-t > 0.001
82
- f.printf "%.3f %d\n", t, y_pre
83
- t = a[i][0]
84
- f.printf "%.3f %d\n", t, y
85
- end
86
- y += a[i][1]
87
- y_pre = y
88
- y_max = y if y > y_max
89
- i += 1
80
+ while i < n
81
+ if a[i][0]-t > 0.001
82
+ para.push "%.3f %d" % [t, y_pre]
83
+ t = a[i][0]
84
+ para.push "%.3f %d" % [t, y]
90
85
  end
91
- rescue
92
- p a[i]
86
+ y += a[i][1]
87
+ y_pre = y
88
+ y_max = y if y > y_max
89
+ i += 1
93
90
  end
91
+ rescue
92
+ p a[i]
94
93
  end
95
94
 
96
95
  t_end = (a.last)[0]
97
96
 
98
- IO.popen("gnuplot","r+") do |f|
99
- f.puts "
97
+ if system("which gnuplot >/dev/null 2>&1")
98
+ IO.popen("gnuplot","r+") do |f|
99
+ f.print "
100
100
  set terminal #{fmt}
101
- set output '#{base}.#{fmt}'
102
- #set rmargin 10
103
- set title '#{base}'
101
+ set output '#{fimg}'
104
102
  set xlabel 'time (sec)'
105
- set ylabel 'parallelism'
103
+ set ylabel '# of cores'
104
+ set ytics nomirror
106
105
 
107
106
  set arrow 1 from #{t_end},#{y_max*0.5} to #{t_end},0 linecolor rgb 'blue'
108
- set label 1 at first #{t_end},#{y_max*0.5} right \"#{t_end}\\nsec\" textcolor rgb 'blue'
107
+ set label 1 \"#{t_end}\\nsec\" at first #{t_end},#{y_max*0.5} right front textcolor rgb 'blue'
109
108
 
110
- plot '#{fpara}' w l axis x1y1 title 'parallelism'
109
+ plot '-' w l notitle
111
110
  "
111
+ para.each do |x|
112
+ f.puts x
113
+ end
114
+ end
112
115
  end
113
116
 
114
- #puts "Parallelism plot: #{base}.#{fmt}"
117
+ #puts "Parallelism plot: #{fimg}"
118
+ fimg
115
119
  end
116
120
 
117
121
 
@@ -154,10 +158,8 @@ plot '#{fpara}' w l axis x1y1 title 'parallelism'
154
158
  f.print "
155
159
  set terminal #{fmt}
156
160
  set output '#{fimg}'
157
- #set rmargin 10
158
- set title '#{base}'
159
161
  set xlabel 'time (sec)'
160
- set ylabel 'parallelism'
162
+ set ylabel '# of cores'
161
163
  set y2tics
162
164
  set ytics nomirror
163
165
  set y2label 'exec/sec'
@@ -291,9 +293,8 @@ plot '-' w l axis x1y1 title 'parallelism', '-' w l axis x1y2 title 'exec/sec'
291
293
  f.print "
292
294
  set terminal #{fmt}
293
295
  set output '#{fimg}'
294
- set title '#{base}'
295
296
  set xlabel 'time (sec)'
296
- set ylabel 'parallelism'
297
+ set ylabel '# of cores'
297
298
  "
298
299
  f.print "plot "
299
300
  f.puts para.map{|cmd,re| "'-' w l title #{cmd.inspect}"}.join(",")
@@ -227,7 +227,7 @@ EOL
227
227
  end
228
228
  html << "</table>\n"
229
229
  html << "<h2>Parallelism</h2>\n"
230
- fimg = Parallelism.plot_parallelism2(@sh_table,@base,@img_fmt)
230
+ fimg = Parallelism.plot_parallelism(@sh_table,@base,@img_fmt)
231
231
  html << "<img src='./#{File.basename(fimg)}' align='top'/></br>\n"
232
232
 
233
233
  html << "<h2>Parallelism by command</h2>\n"
@@ -238,11 +238,9 @@ EOL
238
238
  fimg2 = Parallelism.plot_parallelism_by_host(@sh_table,@base,@img_fmt)
239
239
  html << "<img src='./#{File.basename(fimg2)}' align='top'/></br>\n"
240
240
 
241
- html << "<h2>Command statistics</h2>\n"
241
+ html << "<h2>Command time statistics</h2>\n"
242
242
  html << "<table>\n"
243
- html << "<tr><th>command</th>"
244
243
  html << Stat.html_th
245
- html << "</tr>\n"
246
244
  @cmd_stat.each do |cmd,stat|
247
245
  html << "<tr><td>#{cmd}</td>"
248
246
  html << stat.html_td
@@ -10,9 +10,9 @@ module Pwrake
10
10
  @max = data.max
11
11
  @sum = data.inject(0){|s,x| s+x}
12
12
  @mean = @sum/@n
13
- @median = _median
13
+ @median = calc_median
14
14
  @mean_absolute_deviation = data.inject(0){|s,x| (x-@mean).abs} / @n
15
- if @n>1
15
+ if false and @n>1
16
16
  @variance = data.inject(0){|s,x| y=x-@mean; y**2} / (@n-1)
17
17
  @sdev = Math.sqrt(@variance)
18
18
  @skew = data.inject(0){|s,x| y=(x-@mean)/@sdev; y**3} / @n
@@ -55,7 +55,7 @@ module Pwrake
55
55
  end
56
56
  end
57
57
 
58
- def _median
58
+ def calc_median
59
59
  if @n==1
60
60
  @data[0]
61
61
  elsif @n==2
@@ -73,53 +73,34 @@ module Pwrake
73
73
  end
74
74
  end
75
75
 
76
- def report
77
- case @n
78
- when 0
79
- "no data"
80
- when 1
81
- "n=1 mean=%g"%@mean
82
- else
83
- "n=%i mean=%g median=%g min=%g max=%g sdev=%g skew=%g kurt=%g" %
84
- [@n, @mean, @median, @min, @max, @sdev||0, @skew||0, @kurt||0]
85
- "n=%i mean=%g median=%g min=%g max=%g sdev=%g" %
86
- [@n, @mean, @median, @min, @max, @sdev||0]
87
- end
88
- end
89
-
90
- def stat_array
91
- [@n, @mean, @median, @min, @max, @sdev||0]
92
- end
93
-
94
76
  def fmt(x)
95
77
  case x
96
78
  when Numeric
97
- "%g"%x
79
+ a = x.abs
80
+ if a == 0
81
+ "0"
82
+ elsif a < 1
83
+ "%.3g" % x
84
+ else
85
+ "%.3f" % x
86
+ end
98
87
  else
99
88
  x.to_s
100
89
  end
101
90
  end
102
91
 
103
92
  def html_td
104
- "<td>%i</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>" %
105
- [@n, fmt(@mean), fmt(@median), fmt(@min), fmt(@max), fmt(@sdev)]
93
+ '<td align="right">%i</td><td align="right">%s</td><td align="right">%s</td><td align="right">%s</td><td align="right">%s</td><td align="right">%s</td>' %
94
+ [@n, fmt(@sum), fmt(@mean), fmt(@median), fmt(@min), fmt(@max)]
106
95
  end
107
96
 
108
97
  def self.html_th
109
- "<th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th>" %
110
- %w[n mean median min max sdev]
111
- end
112
-
113
- def report2
114
- case @n
115
- when 0
116
- " no data"
117
- when 1
118
- " n=1\n mean=%g"%@mean
119
- else
120
- " n=%i\n mean=%g\n median=%g\n min=%g\n max=%g\n sdev=%g\n skew=%g\n kurt=%g" %
121
- [@n, @mean, @median, @min, @max, @sdev||0, @skew||0, @kurt||0]
122
- end
98
+ a = %w[command count sum mean median min max]
99
+ "<tr>" + "<th></th>"*2 +
100
+ "<th colspan=#{a.size-2}>time (seconds)</th>" +
101
+ "</tr>\n<tr>" +
102
+ "<th>%s</th>" * a.size % a +
103
+ "</tr>\n"
123
104
  end
124
105
 
125
106
  end
@@ -0,0 +1,16 @@
1
+ module Pwrake
2
+
3
+ module FileTaskAlgorithm
4
+
5
+ # Cache time stamp to reduce load on file system.
6
+ def timestamp
7
+ @file_mtime ||
8
+ if File.exist?(name)
9
+ @file_mtime = File.mtime(name.to_s)
10
+ else
11
+ Rake::LATE
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -33,8 +33,8 @@ module Pwrake
33
33
  new_chain = InvocationChain.append(self, invocation_chain)
34
34
  @lock.synchronize do
35
35
  if application.options.trace
36
- #Log.debug "** Search #{name} #{format_search_flags}"
37
- application.trace "** Search #{name} #{format_search_flags}"
36
+ #Log.debug "** Search #{name}#{format_search_flags}"
37
+ application.trace "** Search #{name}#{format_search_flags}"
38
38
  end
39
39
 
40
40
  return true if @already_finished # <<--- competition !!!
@@ -80,7 +80,7 @@ module Pwrake
80
80
  flags << "finished" if @already_finished
81
81
  flags << "first_time" unless @already_searched
82
82
  flags << "not_needed" unless needed?
83
- flags.empty? ? "" : "(" + flags.join(", ") + ")"
83
+ flags.empty? ? "" : " (" + flags.join(", ") + ")"
84
84
  end
85
85
  private :format_search_flags
86
86
 
@@ -1,3 +1,3 @@
1
1
  module Pwrake
2
- VERSION = "2.2.7"
2
+ VERSION = "2.2.8"
3
3
  end
@@ -9,21 +9,24 @@ module Pwrake
9
9
  @out = $stderr
10
10
  @mutex = Mutex.new
11
11
  @cond_hb = true
12
- @heartbeat = 120
12
+ @heartbeat = nil
13
13
  @thread = Thread.new{ heartbeat_loop }
14
14
  end
15
15
 
16
16
  attr_accessor :out
17
17
 
18
18
  def heartbeat=(t)
19
- @heartbeat = t.to_i
19
+ if t
20
+ t = t.to_i
21
+ t = 15 if t < 15
22
+ end
23
+ @heartbeat = t
20
24
  @thread.run
21
25
  end
22
26
 
23
27
  def heartbeat_loop
24
- sleep
25
28
  loop do
26
- sleep(@heartbeat)
29
+ @heartbeat ? sleep(@heartbeat) : sleep
27
30
  if @cond_hb
28
31
  _puts "heartbeat"
29
32
  end
@@ -36,9 +39,9 @@ module Pwrake
36
39
  end
37
40
 
38
41
  def puts(s)
42
+ _puts(s)
39
43
  @cond_hb = false
40
44
  @thread.run
41
- _puts(s)
42
45
  end
43
46
 
44
47
  def flush
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parallel and distributed Rake for workflow execution on multicores, clusters,
14
14
  clouds using SSH. It has locality-aware scheduling designed for Gfarm file system.
@@ -70,6 +70,7 @@ files:
70
70
  - lib/pwrake/report/report_multi.rb
71
71
  - lib/pwrake/report/stat.rb
72
72
  - lib/pwrake/report/task_stat.rb
73
+ - lib/pwrake/task/file_task_algorithm.rb
73
74
  - lib/pwrake/task/task_algorithm.rb
74
75
  - lib/pwrake/task/task_manager.rb
75
76
  - lib/pwrake/task/task_property.rb
@@ -121,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.7.6
125
+ rubygems_version: 3.0.1
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Parallel and distributed Rake for workflow execution on multicores, clusters,