pwrake 0.9.9.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGES_V2.md +90 -0
  4. data/{LICENSE.txt → MIT-LICENSE} +2 -3
  5. data/README +12 -0
  6. data/README.md +75 -52
  7. data/bin/gfwhere-pipe +23 -12
  8. data/bin/pwrake +22 -29
  9. data/bin/pwrake_branch +24 -0
  10. data/lib/pwrake/branch.rb +22 -0
  11. data/lib/pwrake/branch/branch.rb +213 -0
  12. data/lib/pwrake/branch/branch_application.rb +53 -0
  13. data/lib/pwrake/branch/fiber_queue.rb +36 -0
  14. data/lib/pwrake/branch/file_utils.rb +101 -0
  15. data/lib/pwrake/branch/shell.rb +231 -0
  16. data/lib/pwrake/{profiler.rb → branch/shell_profiler.rb} +28 -27
  17. data/lib/pwrake/branch/worker_communicator.rb +104 -0
  18. data/lib/pwrake/{gfarm_feature.rb → gfarm/gfarm_path.rb} +2 -100
  19. data/lib/pwrake/gfarm/gfarm_postprocess.rb +53 -0
  20. data/lib/pwrake/iomux/channel.rb +70 -0
  21. data/lib/pwrake/iomux/handler.rb +124 -0
  22. data/lib/pwrake/iomux/handler_set.rb +35 -0
  23. data/lib/pwrake/iomux/runner.rb +62 -0
  24. data/lib/pwrake/logger.rb +3 -150
  25. data/lib/pwrake/master.rb +30 -137
  26. data/lib/pwrake/master/fiber_pool.rb +69 -0
  27. data/lib/pwrake/master/idle_cores.rb +30 -0
  28. data/lib/pwrake/master/master.rb +345 -0
  29. data/lib/pwrake/master/master_application.rb +150 -0
  30. data/lib/pwrake/master/postprocess.rb +16 -0
  31. data/lib/pwrake/{graphviz.rb → misc/graphviz.rb} +0 -0
  32. data/lib/pwrake/{mcgp.rb → misc/mcgp.rb} +63 -42
  33. data/lib/pwrake/option/host_map.rb +158 -0
  34. data/lib/pwrake/option/option.rb +357 -0
  35. data/lib/pwrake/option/option_filesystem.rb +112 -0
  36. data/lib/pwrake/queue/locality_aware_queue.rb +158 -0
  37. data/lib/pwrake/queue/no_action_queue.rb +67 -0
  38. data/lib/pwrake/queue/queue_array.rb +366 -0
  39. data/lib/pwrake/queue/task_queue.rb +164 -0
  40. data/lib/pwrake/report.rb +1 -0
  41. data/lib/pwrake/report/parallelism.rb +9 -3
  42. data/lib/pwrake/report/report.rb +50 -103
  43. data/lib/pwrake/report/task_stat.rb +83 -0
  44. data/lib/pwrake/task/task_algorithm.rb +107 -0
  45. data/lib/pwrake/task/task_manager.rb +32 -0
  46. data/lib/pwrake/task/task_property.rb +98 -0
  47. data/lib/pwrake/task/task_rank.rb +48 -0
  48. data/lib/pwrake/task/task_wrapper.rb +296 -0
  49. data/lib/pwrake/version.rb +1 -1
  50. data/lib/pwrake/worker/executor.rb +169 -0
  51. data/lib/pwrake/worker/gfarm_directory.rb +90 -0
  52. data/lib/pwrake/worker/invoker.rb +199 -0
  53. data/lib/pwrake/worker/load.rb +14 -0
  54. data/lib/pwrake/worker/log_executor.rb +73 -0
  55. data/lib/pwrake/worker/shared_directory.rb +74 -0
  56. data/lib/pwrake/worker/worker_main.rb +14 -0
  57. data/lib/pwrake/worker/writer.rb +59 -0
  58. data/setup.rb +1212 -1502
  59. data/spec/003/Rakefile +2 -2
  60. data/spec/008/Rakefile +2 -1
  61. data/spec/009/Rakefile +1 -1
  62. data/spec/009/pwrake_conf.yaml +1 -3
  63. data/spec/hosts +0 -2
  64. data/spec/pwrake_spec.rb +9 -8
  65. metadata +50 -21
  66. data/lib/pwrake.rb +0 -19
  67. data/lib/pwrake/application.rb +0 -232
  68. data/lib/pwrake/counter.rb +0 -54
  69. data/lib/pwrake/file_utils.rb +0 -98
  70. data/lib/pwrake/gfwhere_pool.rb +0 -109
  71. data/lib/pwrake/host_list.rb +0 -88
  72. data/lib/pwrake/locality_aware_queue.rb +0 -413
  73. data/lib/pwrake/option.rb +0 -400
  74. data/lib/pwrake/rake_modify.rb +0 -14
  75. data/lib/pwrake/shell.rb +0 -186
  76. data/lib/pwrake/task_algorithm.rb +0 -475
  77. data/lib/pwrake/task_queue.rb +0 -633
  78. data/lib/pwrake/timer.rb +0 -22
@@ -1,9 +1,9 @@
1
1
  task :first do |t, args|
2
- puts "#{args.x},#{args.y}"
2
+ puts "first x=#{args.x},y=#{args.y}"
3
3
  end
4
4
 
5
5
  task :hello, ['x', 'y'] => :first do |t, args|
6
- puts "#{args.x},#{args.y}"
6
+ puts "hello x=#{args.x},y=#{args.y}"
7
7
  end
8
8
 
9
9
  task :default => :hello
@@ -1,3 +1,4 @@
1
1
  task :default do
2
- puts "this message should not be printed"
2
+ #puts "this message should not be printed"
3
+ sh "hostname; echo ENV1=$ENV1"
3
4
  end
@@ -15,4 +15,4 @@ end
15
15
  task :default => A
16
16
 
17
17
  CLEAN.include A,B
18
- CLEAN.include '*.csv'
18
+ CLEAN.include 'Pwrake*'
@@ -1,3 +1 @@
1
- PROFILE : true
2
- GNU_TIME : true
3
- #TASKLOG : true
1
+ LOG_DIR: true
data/spec/hosts CHANGED
@@ -1,3 +1 @@
1
1
  localhost 4
2
- #tsukuba001 2
3
- #tsukuba002 2
@@ -1,9 +1,10 @@
1
+ require "rspec/its"
2
+
1
3
  $spec_dir = File.expand_path(File.dirname(__FILE__))
2
4
  require $spec_dir+"/helper"
3
5
  $hosts = $spec_dir+"/hosts"
4
6
 
5
7
  RSpec.configure do |config|
6
- config.treat_symbols_as_metadata_keys_with_true_values = true
7
8
  config.filter_run :focus
8
9
  config.run_all_when_everything_filtered = true
9
10
  end
@@ -38,7 +39,7 @@ describe Helper do
38
39
  context "dir=003 w task argument" do
39
40
  subject { Helper.new("003","hello[foo,bar]").run }
40
41
  it { should be_success }
41
- its(:result) { should eq "foo,bar\nfoo,bar\n" }
42
+ its(:result) { should eq "first x=foo,y=bar\nhello x=foo,y=bar\n" }
42
43
  end
43
44
 
44
45
  context "dir=004 -j4 elapsed time" do
@@ -61,12 +62,12 @@ describe Helper do
61
62
  its(:result) { should eq "pass_successfully\n" }
62
63
  end
63
64
 
64
- # context "dir=007 invoke-in-task", :focus=>true do
65
- context "dir=007 invoke-in-task" do
66
- subject { Helper.new("007","-j10").run }
67
- it { should be_success }
68
- its(:elapsed_time) { should be_within(1).of(2) } # 1..3 sec
69
- end
65
+ ## context "dir=007 invoke-in-task", :focus=>true do
66
+ #context "dir=007 invoke-in-task" do
67
+ # subject { Helper.new("007","-j10").run }
68
+ # it { should be_success }
69
+ # its(:elapsed_time) { should be_within(1).of(2) } # 1..3 sec
70
+ #end
70
71
 
71
72
  context "dir=008 --show-conf & PASS_ENV" do
72
73
  subject { Helper.new("008","--show-conf ENV1=hoge").run }
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: 0.9.9.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parallel workflow extension for Rake
14
14
  email:
@@ -16,41 +16,70 @@ email:
16
16
  executables:
17
17
  - gfwhere-pipe
18
18
  - pwrake
19
+ - pwrake_branch
19
20
  extensions: []
20
21
  extra_rdoc_files: []
21
22
  files:
22
23
  - ".gitignore"
24
+ - CHANGES_V2.md
23
25
  - Gemfile
24
- - LICENSE.txt
26
+ - MIT-LICENSE
27
+ - README
25
28
  - README.md
26
29
  - Rakefile
27
30
  - bin/gfwhere-pipe
28
31
  - bin/pwrake
29
- - lib/pwrake.rb
30
- - lib/pwrake/application.rb
31
- - lib/pwrake/counter.rb
32
- - lib/pwrake/file_utils.rb
33
- - lib/pwrake/gfarm_feature.rb
34
- - lib/pwrake/gfwhere_pool.rb
35
- - lib/pwrake/graphviz.rb
36
- - lib/pwrake/host_list.rb
37
- - lib/pwrake/locality_aware_queue.rb
32
+ - bin/pwrake_branch
33
+ - lib/pwrake/branch.rb
34
+ - lib/pwrake/branch/branch.rb
35
+ - lib/pwrake/branch/branch_application.rb
36
+ - lib/pwrake/branch/fiber_queue.rb
37
+ - lib/pwrake/branch/file_utils.rb
38
+ - lib/pwrake/branch/shell.rb
39
+ - lib/pwrake/branch/shell_profiler.rb
40
+ - lib/pwrake/branch/worker_communicator.rb
41
+ - lib/pwrake/gfarm/gfarm_path.rb
42
+ - lib/pwrake/gfarm/gfarm_postprocess.rb
43
+ - lib/pwrake/iomux/channel.rb
44
+ - lib/pwrake/iomux/handler.rb
45
+ - lib/pwrake/iomux/handler_set.rb
46
+ - lib/pwrake/iomux/runner.rb
38
47
  - lib/pwrake/logger.rb
39
48
  - lib/pwrake/master.rb
40
- - lib/pwrake/mcgp.rb
41
- - lib/pwrake/option.rb
42
- - lib/pwrake/profiler.rb
43
- - lib/pwrake/rake_modify.rb
49
+ - lib/pwrake/master/fiber_pool.rb
50
+ - lib/pwrake/master/idle_cores.rb
51
+ - lib/pwrake/master/master.rb
52
+ - lib/pwrake/master/master_application.rb
53
+ - lib/pwrake/master/postprocess.rb
54
+ - lib/pwrake/misc/graphviz.rb
55
+ - lib/pwrake/misc/mcgp.rb
56
+ - lib/pwrake/option/host_map.rb
57
+ - lib/pwrake/option/option.rb
58
+ - lib/pwrake/option/option_filesystem.rb
59
+ - lib/pwrake/queue/locality_aware_queue.rb
60
+ - lib/pwrake/queue/no_action_queue.rb
61
+ - lib/pwrake/queue/queue_array.rb
62
+ - lib/pwrake/queue/task_queue.rb
44
63
  - lib/pwrake/report.rb
45
64
  - lib/pwrake/report/parallelism.rb
46
65
  - lib/pwrake/report/report.rb
47
66
  - lib/pwrake/report/report_multi.rb
48
67
  - lib/pwrake/report/stat.rb
49
- - lib/pwrake/shell.rb
50
- - lib/pwrake/task_algorithm.rb
51
- - lib/pwrake/task_queue.rb
52
- - lib/pwrake/timer.rb
68
+ - lib/pwrake/report/task_stat.rb
69
+ - lib/pwrake/task/task_algorithm.rb
70
+ - lib/pwrake/task/task_manager.rb
71
+ - lib/pwrake/task/task_property.rb
72
+ - lib/pwrake/task/task_rank.rb
73
+ - lib/pwrake/task/task_wrapper.rb
53
74
  - lib/pwrake/version.rb
75
+ - lib/pwrake/worker/executor.rb
76
+ - lib/pwrake/worker/gfarm_directory.rb
77
+ - lib/pwrake/worker/invoker.rb
78
+ - lib/pwrake/worker/load.rb
79
+ - lib/pwrake/worker/log_executor.rb
80
+ - lib/pwrake/worker/shared_directory.rb
81
+ - lib/pwrake/worker/worker_main.rb
82
+ - lib/pwrake/worker/writer.rb
54
83
  - pwrake.gemspec
55
84
  - setup.rb
56
85
  - spec/001/Rakefile
@@ -90,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
119
  version: '0'
91
120
  requirements: []
92
121
  rubyforge_project:
93
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.5
94
123
  signing_key:
95
124
  specification_version: 4
96
125
  summary: Adding Parallel and Distributed feature to Rake
@@ -1,19 +0,0 @@
1
- require "thread"
2
- require "pathname"
3
-
4
- require "pwrake/version"
5
-
6
- require "pwrake/logger"
7
- require "pwrake/timer"
8
- require "pwrake/counter"
9
- require "pwrake/file_utils"
10
- require "pwrake/profiler"
11
- require "pwrake/shell"
12
- require "pwrake/task_algorithm"
13
- require "pwrake/task_queue"
14
- require "pwrake/host_list"
15
- require "pwrake/option"
16
- require "pwrake/master"
17
- require "pwrake/application"
18
-
19
- require "pwrake/rake_modify"
@@ -1,232 +0,0 @@
1
- module Rake
2
- class << self
3
- def application
4
- @application ||= Pwrake.application
5
- end
6
- end
7
- end
8
-
9
-
10
- module Pwrake
11
-
12
- class << self
13
- def application
14
- @application ||= Application.new
15
- end
16
- end
17
-
18
- class Application < ::Rake::Application
19
-
20
- def filesystem
21
- @master.filesystem
22
- end
23
-
24
- def task_queue
25
- @master.task_queue
26
- end
27
-
28
- def finish_queue
29
- @master.finish_queue
30
- end
31
-
32
- def postprocess(t)
33
- if @master.postprocess
34
- @master.postprocess.postprocess(t)
35
- end
36
- end
37
-
38
- def thread_loop(*args)
39
- @master.thread_loop(*args)
40
- end
41
-
42
- def pwrake_options
43
- @master.pwrake_options
44
- end
45
-
46
- def start_worker
47
- @master.start
48
- end
49
-
50
- def host_list
51
- @master.host_list
52
- end
53
-
54
- def task_logger
55
- @master.task_logger
56
- end
57
-
58
- def task_id_counter
59
- @master.task_id_counter
60
- end
61
-
62
- # Run the Pwrake application.
63
- def run
64
- standard_exception_handling do
65
- init("pwrake")
66
- @master = Master.new
67
- @master.init
68
- load_rakefile
69
- begin
70
- begin
71
- top_level
72
- rescue
73
- puts $!.message
74
- end
75
- ensure
76
- @master.finish
77
- end
78
- end
79
- end
80
-
81
- # Run the top level tasks of a Rake application.
82
- def top_level
83
- standard_exception_handling do
84
- if options.show_tasks
85
- display_tasks_and_comments
86
- elsif options.show_prereqs
87
- display_prerequisites
88
- else
89
- top_level_tasks.each { |task_name| invoke_task(task_name) }
90
- end
91
- end
92
- end
93
-
94
-
95
- def standard_rake_options
96
- opts = super
97
- opts.each_with_index do |a,i|
98
- if a[0] == '--version'
99
- a[3] = lambda { |value|
100
- puts "rake, version #{RAKEVERSION}"
101
- puts "pwrake, version #{Pwrake::VERSION}"
102
- exit
103
- }
104
- end
105
- end
106
-
107
- opts.concat(
108
- [
109
- ['-F', '--hostfile FILE',
110
- "[Pw] Read hostnames from FILE",
111
- lambda { |value|
112
- options.hostfile = value
113
- }
114
- ],
115
- ['-j', '--jobs [N]',
116
- "[Pw] Number of threads at localhost (default: # of processors)",
117
- lambda { |value|
118
- if value
119
- value = value.to_i
120
- if value > 0
121
- options.num_threads = value
122
- else
123
- options.num_threads = x = processor_count + value
124
- raise "negative/zero number of threads (#{x})" if x <= 0
125
- end
126
- else
127
- options.num_threads = processor_count
128
- end
129
- }
130
- ],
131
- ['-L', '--logfile [FILE]', "[Pw] Write log to FILE",
132
- lambda { |value|
133
- if value.kind_of? String
134
- options.logfile = value
135
- else
136
- options.logfile = ""
137
- end
138
- }
139
- ],
140
- ['--ssh-opt', '--ssh-option OPTION', "[Pw] Option passed to SSH",
141
- lambda { |value|
142
- options.ssh_option = value
143
- }
144
- ],
145
- ['--filesystem FILESYSTEM', "[Pw] Specify FILESYSTEM (nfs|gfarm)",
146
- lambda { |value|
147
- options.filesystem = value
148
- }
149
- ],
150
- ['--gfarm', "[Pw] FILESYSTEM=gfarm",
151
- lambda { |value|
152
- options.filesystem = "gfarm"
153
- }
154
- ],
155
- ['-A', '--disable-affinity', "[Pw] Turn OFF affinity (AFFINITY=off)",
156
- lambda { |value|
157
- options.disable_affinity = true
158
- }
159
- ],
160
- ['-S', '--disable-steal', "[Pw] Turn OFF task steal",
161
- lambda { |value|
162
- options.disable_steal = true
163
- }
164
- ],
165
- ['-d', '--debug',
166
- "[Pw] Output Debug messages",
167
- lambda { |value|
168
- options.debug = true
169
- }
170
- ],
171
- ['--pwrake-conf [FILE]',
172
- "[Pw] Pwrake configuation file in YAML",
173
- lambda {|value| options.pwrake_conf = value}
174
- ],
175
- ['--show-conf','--show-config',
176
- "[Pw] Show Pwrake configuration options",
177
- lambda {|value| options.show_conf = true }
178
- ],
179
- ['--report LOG', "[Pw] Report profile HTML from LOG and exit.",
180
- lambda { |value|
181
- require 'pwrake/report'
182
- Report.new(File.basename(value.sub(/\.[^.]+$/,"")),[]).report_html
183
- exit
184
- }
185
- ]
186
-
187
- ])
188
- opts
189
- end
190
-
191
-
192
- def count(host_list, host)
193
- @master.counter.count( host_list, host )
194
- end
195
-
196
- =begin
197
- def host_weigts
198
- @master.counter.host_weights
199
- end
200
- =end
201
-
202
- # from Michael Grosser's parallel
203
- # https://github.com/grosser/parallel
204
- def processor_count
205
- host_os = RbConfig::CONFIG['host_os']
206
- case host_os
207
- when /linux|cygwin/
208
- ncpu = 0
209
- open("/proc/cpuinfo").each do |l|
210
- ncpu += 1 if /^processor\s+: \d+/=~l
211
- end
212
- ncpu
213
- when /darwin9/
214
- `hwprefs cpu_count`.to_i
215
- when /darwin/
216
- (hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
217
- when /(open|free)bsd/
218
- `sysctl -n hw.ncpu`.to_i
219
- when /mswin|mingw/
220
- require 'win32ole'
221
- wmi = WIN32OLE.connect("winmgmts://")
222
- cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
223
- cpu.to_enum.first.NumberOfLogicalProcessors
224
- when /solaris2/
225
- `psrinfo -p`.to_i # physical cpus
226
- else
227
- raise "Unknown architecture: #{host_os}"
228
- end
229
- end
230
-
231
- end
232
- end
@@ -1,54 +0,0 @@
1
- module Pwrake
2
-
3
- class Counter
4
-
5
- def initialize
6
- @same = 0
7
- @diff = 0
8
- @total = 0
9
- @same_hosts = {}
10
- @diff_hosts = {}
11
- @no_queue = 0
12
- @found_queue = 0
13
- @empty_queue = 0
14
- end
15
-
16
- def count(host_list, host)
17
- @total += 1
18
- if host_list and host_list.include?(host)
19
- @same += 1
20
- @same_hosts[host] = (@same_hosts[host]||0) + 1
21
- else
22
- @diff += 1
23
- @diff_hosts[host] = (@diff_hosts[host]||0) + 1
24
- end
25
- end
26
-
27
- def print
28
- s = "same=#{@same}, diff=#{@diff}, total=#{@total}\n"
29
- s << "same_hosts = {\n"
30
- @same_hosts.keys.sort.each do |k|
31
- s << " #{k}: #{@same_hosts[k]}\n"
32
- end
33
- s << "}\n"
34
- s << "different_hosts = {\n"
35
- @diff_hosts.keys.sort.each do |k|
36
- s << " #{k}: #{@diff_hosts[k]}\n"
37
- end
38
- s << "}"
39
- Log.info s
40
- end
41
-
42
- def no_queue
43
- @no_queue += 1
44
- end
45
-
46
- def found_queue
47
- @found_queue += 1
48
- end
49
-
50
- def empty_queue
51
- @empty_queue += 1
52
- end
53
- end
54
- end