Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using jemalloc instead of tcmalloc. #2773

Merged
merged 22 commits into from
Aug 2, 2018
Merged

Using jemalloc instead of tcmalloc. #2773

merged 22 commits into from
Aug 2, 2018

Conversation

alexey-milovidov
Copy link
Member

@alexey-milovidov alexey-milovidov commented Aug 1, 2018

In ClickHouse we do many medium-sized allocations of arrays (tens of kilobytes to few megabytes).
Not every allocator is good at this scenario. If the allocator fails to cache these allocations, performance will be terrible due to page faults.

We have used tcmalloc, but we had to tune it:

/** Without this option, tcmalloc returns memory to OS too frequently for medium-sized memory allocations
      *  (like IO buffers, column vectors, hash tables, etc.),
      *  that lead to page faults and significantly hurts performance.
      */
    MallocExtension::instance()->SetNumericProperty("tcmalloc.aggressive_memory_decommit", false);

But in some scenarios it still looks to be working suboptimal:

  13.24%  clickhouse                      [.] tcmalloc::CentralFreeList::RemoveRange
   6.67%  clickhouse                      [.] tcmalloc::ThreadCache::ReleaseToCentralCache
   5.20%  clickhouse                      [.] tcmalloc::CentralFreeList::InsertRange

When using jemalloc, there are no such issues even without any tuning.
Some queries will run faster up to 20%.
Memory usage (RSS) is about 10% lower and is more stable.

In general point of view, jemalloc seems to be better supported and better engineered than tcmalloc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant