[PATCH] D142317: [Support] Avoid using main thread for llvm::parallelFor().

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 08:25:53 PST 2023


andrewng accepted this revision.
andrewng added a comment.
This revision is now accepted and ready to land.

>> I think you need to be a bit careful with terminology because IIUC it's not actually "thread-safe" but a "per thread" allocator. I think this could be useful in some situations but perhaps a better overall approach would be to use a low-level thread aware memory allocator. I think some toolchains/runtimes already have such an allocator and there are other options such as `rpmalloc` and `mimalloc`. This way, the benefit is more widespread and doesn't require any extra effort (although some allocator libraries have some limitations on certain platforms).
>
> Other than limitations on certain platforms, AFAICT, these libraries do not have a notion of memory pools - allocating data in "one big chunk"(To avoid memory fragmentation and to have a possibility to free resources fast). Thus if someone need a thread aware memory pool using `rpmalloc` and `mimalloc` would be not enough.

Yes, as I mentioned in some situations a "memory pool" may be more useful, e.g. more efficient freeing of allocated resources by releasing the pool rather than individual deallocations, although having quickly scanned D142318 <https://reviews.llvm.org/D142318>, it looked like those allocators were long-lived and weren't intended for this use case. I believe that both `rpmalloc` and `mimalloc` already do try to reduce memory fragmentation.

LGTM and thanks for catching this issue!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142317/new/

https://reviews.llvm.org/D142317



More information about the llvm-commits mailing list