Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

why not use multi thread to build objects in test_invoker.rb

Open ChuanJiang0126 opened this issue 9 months ago • 1 comments

@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

ChuanJiang0126 avatar Mar 13 '25 05:03 ChuanJiang0126

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.

mkarlesky avatar Mar 13 '25 17:03 mkarlesky

Fixed in 1.0.2 PR

mvandervoord avatar Jul 09 '25 20:07 mvandervoord