message: Do all three mapping operations in a single thread pool.
diff: @@ -87,11 +87,9 @@ impl LLVMCompiler {
  // TODO: https:/github.com/rayon-rs/rayon/issues/822
  - let merged_bitcode = function_body_inputs
  - .into_iter()
  - .collect::<Vec<_>>()
  - .par_iter()
  - .map_init(
  + let function_body_inputs = function_body_inputs.into_iter().collect::<Vec<_>>();
  +
  + let merged_bitcode = function_body_inputs.par_iter().map_init(
  || {
  let target_machine = self.config().target_machine(target);
  FuncTranslator::new(target_machine)
  @@ -109,17 +107,11 @@ impl LLVMCompiler {
  )?;
  Ok(module.write_bitcode_to_memory().as_slice().to_vec())
  },
  - )
  - .collect::<Result<Vec<_>, CompileError>>()?
  - .into_par_iter();
  + );
  - let trampolines_bitcode = compile_info
  - .module
  - .signatures
  - .iter()
  - .collect::<Vec<_>>()
  - .par_iter()
  - .map_init(
  + let trampolines = compile_info.module.signatures.iter().collect::<Vec<_>>();
  +
  + let trampolines_bitcode = trampolines.par_iter().map_init(
  || {
  let target_machine = self.config().target_machine(target);
  FuncTrampoline::new(target_machine)
  @@ -129,17 +121,11 @@ impl LLVMCompiler {
  let module = func_trampoline.trampoline_to_module(sig, self.config(), &name)?;
  Ok(module.write_bitcode_to_memory().as_slice().to_vec())
  },
  - )
  - .collect::<Result<Vec<_>, CompileError>>()?
  - .into_par_iter();
  + );
  - let dynamic_trampolines_bitcode = compile_info
  - .module
  - .functions
  - .iter()
  - .collect::<Vec<_>>()
  - .par_iter()
  - .map_init(
  + let dynamic_trampolines = compile_info.module.functions.iter().collect::<Vec<_>>();
  +
  + let dynamic_trampolines_bitcode = dynamic_trampolines.par_iter().map_init(
  || {
  let target_machine = self.config().target_machine(target);
  (
  @@ -149,19 +135,18 @@ impl LLVMCompiler {
  },
  |(func_trampoline, signatures), (i, sig)| {
  let sig = &signatures[**sig];
  - let name =
  - symbol_registry.symbol_to_name(Symbol::DynamicFunctionTrampoline(*i));
  + let name = symbol_registry.symbol_to_name(Symbol::DynamicFunctionTrampoline(*i));
  let module =
  func_trampoline.dynamic_trampoline_to_module(sig, self.config(), &name)?;
  Ok(module.write_bitcode_to_memory().as_slice().to_vec())
  },
  - )
  - .collect::<Result<Vec<_>, CompileError>>()?
  - .into_par_iter();
  + );
  let merged_bitcode = merged_bitcode
  .chain(trampolines_bitcode)
  .chain(dynamic_trampolines_bitcode)
  + .collect::<Result<Vec<_>, CompileError>>()?
  + .into_par_iter()
  .reduce_with(|bc1, bc2| {
  let ctx = Context::create();
  let membuf = MemoryBuffer::create_from_memory_range(&bc1, "");
  