google / tcmalloc

Apache License 2.0
4.4k stars 480 forks source link

Provide documentation about how this project differs from gperftools/gperftools #2

Closed acmorrow closed 4 years ago

acmorrow commented 4 years ago

I'm really excited to see this new version of tcmalloc becoming available. In particular, the per-cpu support has long been an idea of interest. However, it is currently quite unclear how this new project compares with the existing gperftools/gperftools project. I think it would be helpful if this project contained some documentation that provided a direct comparison with the other (soon to be legacy?) project. Some roadmap and future directions content would be welcome as well. In no particular order:

I know that is a lot of questions, but I'm hopeful that putting some of the answers down in writing will help everyone who currently uses gperftools in their projects to understand how this new project should be approached.

I'd also like to thank you in advance for all the work that I am certain went into getting this new version of tcmalloc out into the world. Please don't take my long list of questions and concerns as anything other than deriving from a keen interest in the success of this new project.

lathiat commented 4 years ago

The gperftools tcmalloc is quite widely used in the community for example it’s the default in ceph. It’s packaged in Ubuntu etc and had a new release as recently as April 2018 so this is definitely confusing messaging as it’s already very well established in the community.

Link to Ubuntu package for example: https://packages.ubuntu.com/eoan/libtcmalloc-minimal4

Comments in the linked gperftools issue suggest that the two projects are largely different (with distant relation) and at least not currently going to be interchangeable in various circumstances such as cross platform support etc.

I would suggest that this new tcmalloc should either take a new name or at the least be “tcmalloc3” or v3 (the gperftools version is currently v2.7) as it will cause quite a bit of community confusion otherwise I think.

Lastique commented 4 years ago

+1 about renaming this project. No, don't use tcmalloc3 as this implies this is a newer version of gperftools, which it isn't.

chhetripradeep commented 4 years ago

+1 for renaming it. I would pefer naming it tcmalloc-ng :)

ckennelly commented 4 years ago

There are two projects on Github that are based on Google’s internal TCMalloc: This one and gperftools. Both are fast C/C++ memory allocators designed around a fast path that avoids synchronizing with other threads for most allocations.

Google open-sourced its memory allocator as part of “Google Performance Tools” in 2005. As discussed by Titus Winters in his 2017 CppCon Talk and the “Software Engineering at Google” book, it was easy for us to externalize code, but more difficult keeping it in-sync with our internal usage at that time. Subsequently, our internal implementation diverged from the code externally. This project eventually was adopted by the community as “gperftools.”

This repository is Google’s current implementation of TCMalloc, used by ~all of our C++ programs in production. The code is limited to the memory allocator implementation itself. Since “Profiling a Warehouse-Scale Computer” (Kanev 2015), we have invested in improving application productivity via optimizations to the implementation (per-CPU caches, sized delete, fast/slow path improvements, hugepage-aware backend).

Because this repository reflects our day-to-day usage, we’ve focused on the platforms we regularly use and can see extensive testing and optimization.

The configuration on Github mirrors our production defaults, with two notable exceptions:

Over time, we have found that configurability carries a maintenance burden. While a knob can provide immediate flexibility, the increased complexity can cause subtle problems for more rarely used combinations.

Like Abseil, we do not attempt to provide ABI stability. Providing a stable ABI could require compromising performance or adding otherwise unneeded complexity to maintain stability.

In addition to a memory allocator, the gperftools project contains a number of other tools:

alk@, the current maintainer of gperftools, plans to continue to work on that project. gperftools covers use cases this project does not support (stable ABIs, various platforms/OS's, etc.)