Conversation
| file_name.to_str().unwrap() | ||
| )); | ||
| aapt.arg("add") | ||
| .arg("-0") |
There was a problem hiding this comment.
-0 "" disables compression for any file extension.
There was a problem hiding this comment.
This should be rather added to the aapt package command
There was a problem hiding this comment.
@msiglreith I think it should be on both, as the argument only has effect on the files added through that particular command. We don't add any (e.g. heavy .so) files through aapt package, only through aapt add.
|
Thanks! As general feature sth like |
|
If there are no downsides to |
| adb.arg("install").arg("-r").arg(&self.path); | ||
| adb.arg("install") | ||
| .arg("-r") | ||
| .arg("--fastdeploy") |
There was a problem hiding this comment.
Should this be conditional (ref https://stackoverflow.com/a/50009451)?
|
This is an interesting approach, and definitely helpful. In my tests I can get apt installs (excluding rust compile time) down from 12 seconds to 3-4 seconds by using this patch. However, I noticed one caveat - the "fastdeploy" detects random changes of entries inside APK at different compile times. Sometimes its faster (3-4 secs), sometimes slower (~7-10 secs). Figured out it might be because of offsets / order that files are added into the APK by aapt. You can see the file listings with Did one iteration for sorting the library files by modification time (some debug code and other tests included as well) here: This seems to help, but if a file is added to asset folder (added by cargo-apt by I wonder how the APK's actually work. Another approach could be to try if cargo-apk should edit the existing APK (instead of a new?) This all applies to development mode. Release should not use fastdeploy I guess. |
|
Another (very very crude) way to speed up the build & install in some cases: stripping out the debug symbols of bundled libraries. This can be set in In my test project I get APT binary size reduction from 103MB down to 39MB with this. Note: the example below may strip .so's outside target dir too (in runtime_libs folder if defined) - do not run! Example
diff --git a/ndk-build/src/apk.rs b/ndk-build/src/apk.rs
index 1e7eea0..324e5c1 100644
--- a/ndk-build/src/apk.rs
+++ b/ndk-build/src/apk.rs
@@ -78,6 +78,12 @@ impl<'a> UnalignedApk<'a> {
if !path.exists() {
return Err(NdkError::PathNotFound(path.into()));
}
+
+ std::process::Command::new("aarch64-linux-gnu-strip")
+ .arg(path)
+ .output()
+ .unwrap();
+
let abi = target.android_abi();
let file_name = path.file_name().unwrap();
let out = self.0.build_dir.join("lib").join(abi); |
|
@agrande Would you mind if I respin the @blaind Is there anything actionable on what you found above, that we can work into a separate PR that enables I have no idea how to read this (without looking up better docs) nor what "agent files" are, but in some way it feels like this allows us to push "source build" files to the device without even packaging them up through Primarily because I've been using Mozilla's Rust gradle plugin lately, and remembered how quick Android debug deployment actually is. |
|
@MarijnS95 Do whatever you want with this PR, I'm not currently using |
|
Thanks @agrande! I've gone ahead and submitted the |
|
For me, it's been a while since using |
|
With the compression disablement squared away I'll do some profiling on my project to see how big the gains are for |
|
Thanks! Compression disablement was applied in #283, and IIRC empirical testing found that fastdeploy, streaming install and friends seem to be enabled/picked by default. The |
Here are some tweaks that increase the build and install speed a lot for me.
Disabling compression on the apk entries in particular reduced the build time from ~12 seconds to just 2 seconds on my project, which helps a lot with development iteration speed.
This PR is not meant to be merged as it is, but to open a conversation about how this sort of build optimisations could be included in cargo apk, whether as one or multiple command line arguments, or
Cargo.tomloption(s).