debug: Link in the debug version of tcmalloc for debug builds.#5424
debug: Link in the debug version of tcmalloc for debug builds.#5424jmarantz merged 17 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Joshua Marantz <jmarantz@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
This seems like a good idea to me if we can get it passing CI
bazel/envoy_build_system.bzl
Outdated
| repository + "//bazel:opt_build": [] if test else ["-ggdb3"], | ||
| repository + "//bazel:fastbuild_build": [], | ||
| repository + "//bazel:dbg_build": ["-ggdb3"], | ||
| repository + "//bazel:dbg_build": ["-ggdb3", "-DDEBUG_TCMALLOC"], |
There was a problem hiding this comment.
fastbuild sgtm.
Passing CI will be the next hurdle; for some reason the tsan build worked locally on my machine so I must not be using the same options as there are in CI. Will investigate.
|
I ran into trouble solving this due to my lack of understanding of bazel functions. Seeking stackoverflow help: https://stackoverflow.com/questions/53947289/bazel-select-help-configuring-tcmalloc-debug |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
I'm strongly in favor of this, if you can work out the bazel incantations. |
|
I haven't gotten any traction on the stackoverflow question I linked above, but I'm hopeful @htuch will be able to offer some suggestions when he's back online. I'm pretty sure I can get my alternate approach in #5450 working if I can't do this one, but this seems better as it depends directly on code (https://github.com/gperftools/gperftools/blob/master/src/debugallocation.cc) authored by https://en.wikipedia.org/wiki/Urs_H%C3%B6lzle himself :) |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
closing in favor of #5450 which I've been able to get to work. |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
@ggreenway @PiotrSikora let's review this PR instead :) Given that in #5450 I was forcing the user to explicitly configure memory debugging, we might as well use the memory debugging built into tcmalloc, which seems to work better with protobuf's inconsistent operator new/delete overrides. |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ete. Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
Note: since this is now guarded by |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
Sigh, sorry... |
|
...or wait, it doesn't (but perhaps it should???). |
|
I think tcmalloc=disabled is well-covered by tsan, asan, & mac, so it's OK? |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
htuch
left a comment
There was a problem hiding this comment.
Looks good, a few minor comments.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
PiotrSikora
left a comment
There was a problem hiding this comment.
LGTM, but you need to rebase.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
This is really cool. Is there a reason we decided not to do this by default on dbg/fastbuild builds? It seems like this would be nice to have?
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
I added doc. I am in favor of using it in fastbuild and dbg compilation modes, but maybe we can just add the capability now and get some community buy-in before switching the default? |
|
@mattklein123 I've asked to make memory scribbling optional in #5450, since both memory overhead (2-4x) and runtime overhead (educated guess) are quite significant, and would render debug build almost unusable. |
bazel/README.md
Outdated
| * ASSERT() can be configured to log failures and increment a stat counter in a release build with | ||
| `--define log_debug_assert_in_release=enabled`. The default behavior is to compile debug assertions out of | ||
| release builds so that the condition is not evaluated. This option has no effect in debug builds. | ||
| * tcmalloc can be disabled with `--define tcmalloc=disabled` |
There was a problem hiding this comment.
Disabling is in section above (though, I'd argue that we could merge both).
There was a problem hiding this comment.
Moved tcmalloc=disabled to disabling section. Merging can be left for a different PR.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
@PiotrSikora I ran all the tests with 4 different configs (fastbuild vs debug, tcmalloc=debug vs default) on my workstation. By far the greatest overhead for running tests is compiling and I think especially linking them (30-60 minutes for debug builds). After that it takes about 1.5 to 2 minutes to run all 366 tests independent of mode. An example command-line is: The main concern I have with running tests only under tcmalloc=debug is that it is not the same as production. However we have bazel.release in CI so I think we're OK. Obviously it doesn't make sense to load-test or perf-test with memory debugging. |
Per comment thread, the test works, shows what the system does, and we can always delete it if it causes trouble with sanitizers.
…proxy#5424) * debug: Use the debug version of tcmalloc when compiling for debug when --define=tcmalloc=debug is passed to bazel. Signed-off-by: Joshua Marantz <jmarantz@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
Description: Use the debug version of tcmalloc when compiling for debug when --define=tcmalloc=debug is passed to bazel.
Risk Level: low: with this when we debug we are using a different allocator
Testing: //test/...
Docs Changes: n/a
Release Notes: n/a
*Fixes #Issue: #5423