HarmonyOS Compilation Optimization: Config Tweaks That Cut Build Time from 24 to 14 Minutes

This article details practical HarmonyOS compilation optimizations — unified lockfiles, boosted extraction, disabled JS intermediate output, and skipped lib compression — that reduced full builds from 24 to 14 minutes and incremental builds from 4 to 2.5 minutes on a 3-million-line ArkTS codebase.

HarmonyOS Developer Technology
HarmonyOS Developer Technology
HarmonyOS Developer Technology
HarmonyOS Compilation Optimization: Config Tweaks That Cut Build Time from 24 to 14 Minutes

Default Compilation Optimizations

DevEco Studio enables incremental build, parallel build, and daemon processes by default. Developers can verify these settings via the Build Analyzer tool, which shows the status of parallel, incremental, and daemon flags. The article recommends ensuring all three are set to true for maximum build efficiency.

Build Analyzer showing parallel, incremental, daemon settings
Build Analyzer showing parallel, incremental, daemon settings

Scenario-Specific Optimizations for Large Codebases

Using a 3-million-line ArkTS project (500+ modules, 20+ lib libraries) as a case study, the author identifies three bottleneck stages: dependency installation, language compilation, and compression packaging. Targeted optimizations for each stage are described below.

Optimization 1: Dependency Installation

When modules share duplicate dependencies, a unified lockfile at the project level avoids repeated installs. Enable via .ohpmrc:

enable_unified_lockfile=true
enable_boost_extraction_speed=true

— accelerates decompression and traversal of .har / .tgz third-party packages.

Result: dependency installation time dropped from 8 minutes to under 1 minute .

Dependency installation optimization results
Dependency installation optimization results

Optimization 2: Language Compilation (Debug Builds Only)

For local Debug builds, JS intermediate artifacts are unnecessary. Starting with version 6.0.1 (API 21), setting ohos.arkCompile.noEmitJs = true in the build config skips JS intermediate generation during ArkTS compilation.

Full compilation time reduced by ~2 minutes .

Memory consumption during compilation also decreases.

Trade-off: In Release mode with obfuscation or when building HARs that require JS intermediate code, the flag has no effect — JS artifacts are still generated.

Language compilation optimization configuration
Language compilation optimization configuration

Optimization 3: Packaging Compression

Large lib libraries increase compression time. During local development, package size is irrelevant, so compression can be skipped entirely by setting compressNativeLibs = false in module.json5.

Result: packaging task time fell from 1 minute to 3 seconds .

Combined Impact

After applying all three optimizations:

Full compilation: 24 min → 14 min

Incremental compilation: 4 min → 2.5 min

Overall compilation time comparison before and after optimizations
Overall compilation time comparison before and after optimizations

Balancing Memory and Performance

DevEco Studio offers two modes via hvigor-config.json5:

Memory-priority mode (default): lower memory footprint.

Performance-priority mode : enables task caching ( hvigor.enableMemoryCache=true) and sets optimizationStrategy = "performance". This keeps more data resident in memory after compilation, speeding up subsequent builds at the cost of higher baseline memory usage.

Developers should choose based on their machine's available RAM.

Build Method Selection

Choosing the right build target avoids unnecessary work:

For single-module development, use "Make Module '*'" instead of "Make All Modules" to avoid compiling unrelated modules.

When multiple HAP modules (entry/feature) exist but only one is under active development, avoid "Build Hap(s)" — it builds all HAPs. Again, prefer "Make Module '*'".

Build target selection comparison
Build target selection comparison

Incremental Debugging and Hot Reload

For device debugging, use the incremental debug buttons (toolbar icons) to build and push only changed code, drastically reducing push time for large apps. Additionally, Hot Reload applies code changes on save without restarting the app, enabling immediate preview on real devices or emulators.

Further References

Official optimization guide: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-build-optimized

Latest IDE download: https://developer.huawei.com/consumer/cn/download/

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

incremental buildHarmonyOSArkTSDevEco Studiocompilation optimizationbuild performanceHvigorohpm
HarmonyOS Developer Technology
Written by

HarmonyOS Developer Technology

HarmonyOS developers provide key technology analysis, version updates, Codelabs practice, and event information for HarmonyOS. Welcome developers to join the HarmonyOS ecosystem and create infinite possibilities together!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.