Skip to content

Commit

Permalink
ota_extractor: parallelize partition extractions
Browse files Browse the repository at this point in the history
Each sub-partition will be extracted in a separate thread.

A simple test of Nothing Phone 2's series of OTA extractions (2.0.1 ->
2.0.1a -> 2.0.2 -> 2.0.2a -> 2.0.3 -> 2.0.4 -> 2.5.1 -> 2.5.1a ->
2.5.2 -> 2.5.3 -> 2.5.5 -> 2.5.6 -> 2.6.0, 5.1 GiB in total) in
AMD Ryzen Threadripper 7980X gives a speed boost of 2.55x.

[Before]
	Percent of CPU this job got: 102%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 15:57.80

[After]
	Percent of CPU this job got: 258%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 6:15.34

Change-Id: I2dc9ada91ea773f1daeb1a4e7e101f25fb03be07
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
  • Loading branch information
arter97 committed Jul 8, 2024
1 parent 24d8e63 commit 97186d9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions aosp/ota_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <array>
#include <cstdint>
#include <cstdio>
#include <future>
#include <iterator>
#include <memory>

Expand Down Expand Up @@ -197,9 +198,17 @@ bool ExtractImagesFromOTA(const DeltaArchiveManifest& manifest,
const size_t data_begin = metadata.GetMetadataSize() +
metadata.GetMetadataSignatureSize() +
payload_offset;
std::vector<std::future<void>> futures;

for (const auto& partition : manifest.partitions()) {
ExtractImageFromPartitions(manifest, partition, data_begin, payload_fd,
input_dir, output_dir, partitions);
futures.push_back(
std::async(std::launch::async,
ExtractImageFromPartitions, manifest, partition, data_begin, payload_fd,
input_dir, output_dir, partitions)
);
}
for (auto& fut : futures) {
fut.get();
}
return true;
}
Expand Down

0 comments on commit 97186d9

Please sign in to comment.