@@ -89,6 +89,9 @@ fn run_cargo<DB: WriteResults>(
8989 rustflags. push ( ' ' ) ;
9090 rustflags. push_str ( tc_rustflags) ;
9191 }
92+ // Limit debuginfo in an effort to decrease linker peak memory usage, while retaining enough
93+ // information to get useful backtraces.
94+ rustflags. push_str ( " -Cdebuginfo=1" ) ;
9295
9396 let rustflags_env = if let Some ( & "doc" ) = args. get ( 0 ) {
9497 "RUSTDOCFLAGS"
@@ -210,6 +213,7 @@ pub(super) fn run_test<DB: WriteResults>(
210213 ) ;
211214 let sandbox = SandboxBuilder :: new ( )
212215 . memory_limit ( Some ( ctx. config . sandbox . memory_limit . to_bytes ( ) ) )
216+ . cpu_limit ( Some ( f32:: from ( ctx. config . sandbox . cpu_limit ) ) )
213217 . enable_networking ( false ) ;
214218
215219 let krate = & ctx. krate . to_rustwide ( ) ;
@@ -235,28 +239,51 @@ fn build<DB: WriteResults>(
235239 build_env : & Build ,
236240 local_packages_id : & HashSet < PackageId > ,
237241) -> Fallible < ( ) > {
242+ let cpus = ctx. config . sandbox . cpu_limit . to_string ( ) ;
238243 run_cargo (
239244 ctx,
240245 build_env,
241- & [ "build" , "--frozen" , "--message-format=json" ] ,
246+ & [
247+ "build" ,
248+ "--frozen" ,
249+ "--message-format=json" ,
250+ "--jobs" ,
251+ & cpus,
252+ ] ,
242253 true ,
243254 local_packages_id,
244255 ) ?;
245256 run_cargo (
246257 ctx,
247258 build_env,
248- & [ "test" , "--frozen" , "--no-run" , "--message-format=json" ] ,
259+ & [
260+ "test" ,
261+ "--frozen" ,
262+ "--no-run" ,
263+ "--message-format=json" ,
264+ "--jobs" ,
265+ & cpus,
266+ ] ,
249267 true ,
250268 local_packages_id,
251269 ) ?;
252270 Ok ( ( ) )
253271}
254272
255273fn test < DB : WriteResults > ( ctx : & TaskCtx < DB > , build_env : & Build ) -> Fallible < ( ) > {
274+ let cpus = ctx. config . sandbox . cpu_limit . to_string ( ) ;
256275 run_cargo (
257276 ctx,
258277 build_env,
259- & [ "test" , "--frozen" ] ,
278+ & [
279+ "test" ,
280+ "--frozen" ,
281+ "--jobs" ,
282+ & cpus,
283+ "--" ,
284+ "--test-threads" ,
285+ & cpus,
286+ ] ,
260287 false ,
261288 & HashSet :: new ( ) ,
262289 )
@@ -299,6 +326,7 @@ pub(super) fn test_check_only<DB: WriteResults>(
299326 build_env : & Build ,
300327 local_packages_id : & HashSet < PackageId > ,
301328) -> Fallible < TestResult > {
329+ let cpus = ctx. config . sandbox . cpu_limit . to_string ( ) ;
302330 if let Err ( err) = run_cargo (
303331 ctx,
304332 build_env,
@@ -308,6 +336,8 @@ pub(super) fn test_check_only<DB: WriteResults>(
308336 "--all" ,
309337 "--all-targets" ,
310338 "--message-format=json" ,
339+ "--jobs" ,
340+ & cpus,
311341 ] ,
312342 true ,
313343 local_packages_id,
@@ -323,6 +353,7 @@ pub(super) fn test_clippy_only<DB: WriteResults>(
323353 build_env : & Build ,
324354 local_packages_id : & HashSet < PackageId > ,
325355) -> Fallible < TestResult > {
356+ let cpus = ctx. config . sandbox . cpu_limit . to_string ( ) ;
326357 if let Err ( err) = run_cargo (
327358 ctx,
328359 build_env,
@@ -332,6 +363,8 @@ pub(super) fn test_clippy_only<DB: WriteResults>(
332363 "--all" ,
333364 "--all-targets" ,
334365 "--message-format=json" ,
366+ "--jobs" ,
367+ & cpus,
335368 ] ,
336369 true ,
337370 local_packages_id,
@@ -347,6 +380,7 @@ pub(super) fn test_rustdoc<DB: WriteResults>(
347380 build_env : & Build ,
348381 local_packages_id : & HashSet < PackageId > ,
349382) -> Fallible < TestResult > {
383+ let cpus = ctx. config . sandbox . cpu_limit . to_string ( ) ;
350384 let res = run_cargo (
351385 ctx,
352386 build_env,
@@ -356,6 +390,8 @@ pub(super) fn test_rustdoc<DB: WriteResults>(
356390 "--no-deps" ,
357391 "--document-private-items" ,
358392 "--message-format=json" ,
393+ "--jobs" ,
394+ & cpus,
359395 ] ,
360396 true ,
361397 local_packages_id,
0 commit comments