Skip to content

[BUG] ThinLTO is extremely slow on Windows #2254

Open

Description

@gechdcb

Description

I tried enabling ThinLTO on a relatively large project, but the build performance on Windows was much slower than expected. In practice, ThinLTO build time was almost the same as FullLTO, which seems abnormal given ThinLTO’s design.

After investigating, I found that this may be related to the Windows UCRT implementation of malloc/free. As far as I understand, UCRT’s allocator relies on a global lock, which can significantly limit scalability under multithreaded workloads. This appears to cause ThinLTO’s parallel execution to behave much more like single-threaded execution.

Clang seems to provide a way to replace the default malloc/free with a third-party allocator, but it does not appear that NDK enables this by default on Windows.

As an experiment, I used mimalloc-redirect to replace UCRT’s malloc/free, and the improvement was significant:

  • Original NDK r30: build time was around 1 hour 20 minutes
  • Workaround with mimalloc-redirect on NDK r30: build time was around 17 minutes

Based on this, I would suggest that NDK consider using a high-performance allocator by default on Windows instead of the default Windows UCRT allocator, especially for workloads like ThinLTO that depend heavily on parallelism.

I am using a supported NDK

  • I have checked and the NDK I'm using is currently supported

Affected versions

r30

Activity

  1. nickdesaulniers commented on Sep 23, 2026

    @nickdesaulniers
    Member

    Yeah, I'm currently testing out using jemalloc, since Android already has (an old fork of) it tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions