why not use multi thread to build objects in test_invoker.rb
@mvandervoord @mkarlesky
Hi both,
I found at building objects, multi-thread is not used. Why? I tried to modify as below and found it works. So I wonder the reason and consideration of not using multi-thread to build objects. I'll appreciate if you can reply it. Thanks
=begin
# flattern testables to Merge All Test objects, for parallel
flattenobjtbl = {}
start_time = SystemWrapper.time_stopwatch_s()
@batchinator.build_step("Merge All Objects") do
@testables.each do |_, details|
#@loginator.log( "details #{details}")
details[:objects].each do |obj|
item = {}
item[:tool] = details[:tool]
item[:tool][:executable] = 'ccache ' + item[:tool][:executable]
item[:name] = details[:name]
item[:src] = @file_finder.find_build_input_file(filepath: obj, context: context)
flattenobjtbl[obj] = item
end
end
end
end_time = SystemWrapper.time_stopwatch_s()
duration = @reportinator.generate_duration( start_time_s: start_time, end_time_s: end_time )
@loginator.log( "Merge Objects #{duration}", Verbosity::NORMAL)
# Build All Test objects, multi thread
start_time = SystemWrapper.time_stopwatch_s()
@batchinator.build_step("Building Objects") do
@batchinator.exec(workload: :compile, things: flattenobjtbl) do |obj, item|
compile_test_component(tool: item[:tool], context: context, test: item[:name], source: item[:src], object: obj, msg: nil)
end
end
end_time = SystemWrapper.time_stopwatch_s()
duration = @reportinator.generate_duration( start_time_s: start_time, end_time_s: end_time )
@loginator.log( "Building Objects #{duration}", Verbosity::NORMAL)
=end
#=begin
# Build All Test objects, legacy, single thread
start_time = SystemWrapper.time_stopwatch_s()
@batchinator.build_step("Building Objects") do
@testables.each do |_, details|
#@loginator.log( "details #{details}")
#tool = details[:tool]
#tool[:executable] = 'ccache ' + tool[:executable]
details[:objects].each do |obj|
src = @file_finder.find_build_input_file(filepath: obj, context: context)
compile_test_component(tool: details[:tool], context: context, test: details[:name], source: src, object: obj, msg: details[:msg])
end
end
end
end_time = SystemWrapper.time_stopwatch_s()
duration = @reportinator.generate_duration( start_time_s: start_time, end_time_s: end_time )
@loginator.log( "Building Objects #{duration}", Verbosity::NORMAL)
#=end
Hi, @ChuanJiang0126. You're absolutely right that multi-threading should be used. Mark has the full story. I think he explained that a PR merge gone bad silently replaced the key line that causes multi-threaded compilation. This has already been fixed but not yet published in a patched version bump. I'll leave this issue open for Mark to add to and close as appropriate.
Fixed in 1.0.2 PR