Commit 690417a
⚡ Parallelize sequential I/O in harmony/pushy/DownloadTask.ts (#532)
* ⚡ Parallelize sequential file system operations in harmony/pushy/DownloadTask.ts
Optimized multiple I/O-bound loops in the HarmonyOS implementation to use `Promise.all` instead of sequential `await` calls. This significantly reduces total execution time for common update tasks, such as directory listing, manifest reading, and resource copying.
Key improvements:
- `listEntryNames`: Parallelized `fileIo.stat` calls for all entries in a directory.
- `doPatchFromApp`/`doPatchFromPpk`: Parallelized concurrent execution of `listEntryNames` and `readManifestArrays`.
- `copyFromResource`: Parallelized destination copy operations for both media and raw resources.
Measured Improvement Rationale:
Parallelizing independent I/O operations is a standard optimization that leverages the underlying system's ability to handle concurrent requests, leading to lower latency during hot updates. While a baseline could not be established without a full HarmonyOS environment, these changes are functionally equivalent and more efficient.
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
* ⚡ Parallelize sequential I/O and mitigate race conditions in harmony/pushy/DownloadTask.ts
Optimized multiple I/O-bound loops in the HarmonyOS implementation to use `Promise.all` instead of sequential `await` calls. This significantly reduces total execution time for directory listing, manifest reading, and resource copying.
To ensure robustness during parallel operations:
- Hardened `ensureDirectory` to be idempotent by handling concurrent directory creation errors.
- Refactored `copyFromResource` to calculate unique parent directories and pre-create them sequentially before initiating parallel fan-out writes/copies.
Key improvements:
- `listEntryNames`: Parallelized `fileIo.stat` calls.
- `doPatchFromApp`/`doPatchFromPpk`: Parallelized `listEntryNames` and `readManifestArrays`.
- `copyFromResource`: Parallelized destination writes (media) and copies (raw resources) with race condition mitigation.
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>1 parent 13a9e3f commit 690417a
1 file changed
Lines changed: 41 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
102 | | - | |
103 | 108 | | |
| 109 | + | |
104 | 110 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
116 | 114 | | |
117 | | - | |
| 115 | + | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
| |||
432 | 430 | | |
433 | 431 | | |
434 | 432 | | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
440 | 437 | | |
441 | 438 | | |
442 | 439 | | |
| |||
475 | 472 | | |
476 | 473 | | |
477 | 474 | | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
483 | 479 | | |
484 | 480 | | |
485 | 481 | | |
| |||
524 | 520 | | |
525 | 521 | | |
526 | 522 | | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
531 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
532 | 534 | | |
533 | 535 | | |
534 | 536 | | |
535 | 537 | | |
536 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
537 | 546 | | |
538 | 547 | | |
539 | 548 | | |
540 | 549 | | |
541 | | - | |
542 | | - | |
543 | | - | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
544 | 553 | | |
545 | 554 | | |
546 | 555 | | |
| |||
0 commit comments