Allow CompOS VM to use all CPUs by default

In early boot, if dalvik.vm.boot-dex2oat-threads is not specified,
dex2oat will run in #CPU threads.

Currently, we're still using one CPU in the VM if
dalvik.vm.boot-dex2oat-threads not specified. This change gives the VM
the same number of CPUs, which will allow dex2oat to leverage all CPUs.

Bug: 197358423
Test: Run `composd_cmd staged-apex-compile` on oriole
      # Before: ~90s
      # After:  ~60s
Test: enable adb, check /proc/cpuinfo
Change-Id: Ifb8908ab44eacf42960f6e4d9b12edca6370d594
diff --git a/compos/composd/Android.bp b/compos/composd/Android.bp
index 3b545e5..55a3107 100644
--- a/compos/composd/Android.bp
+++ b/compos/composd/Android.bp
@@ -18,6 +18,7 @@
         "libcompos_common",
         "libcomposd_native_rust",
         "libminijail_rust",
+        "libnum_cpus",
         "libnix",
         "liblibc",
         "liblog_rust",
diff --git a/compos/composd/src/instance_manager.rs b/compos/composd/src/instance_manager.rs
index 8950f20..e8c1d9a 100644
--- a/compos/composd/src/instance_manager.rs
+++ b/compos/composd/src/instance_manager.rs
@@ -45,10 +45,14 @@
     pub fn start_pending_instance(&self) -> Result<Arc<CompOsInstance>> {
         let config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
         let mut vm_parameters = VmParameters { config_path, ..Default::default() };
-        vm_parameters.cpus = NonZeroU32::from_str(
-            &system_properties::read(DEX2OAT_THREADS_PROP_NAME).unwrap_or_default(),
-        )
-        .ok();
+        vm_parameters.cpus = match system_properties::read(DEX2OAT_THREADS_PROP_NAME) {
+            Ok(s) => Some(NonZeroU32::from_str(&s)?),
+            Err(_) => {
+                // dex2oat uses all CPUs by default. To match the behavior, give the VM all CPUs by
+                // default.
+                NonZeroU32::new(num_cpus::get() as u32)
+            }
+        };
         vm_parameters.cpu_set = system_properties::read(DEX2OAT_CPU_SET_PROP_NAME).ok();
         self.start_instance(PENDING_INSTANCE_DIR, vm_parameters)
     }