Commit 8232c2cd authored by Stepan Palamarchuk's avatar Stepan Palamarchuk Committed by Praveen Kumar Ramakrishnan

Increase fibers stack size if we're running with ASAN

Summary:
In most cases user is not aware of ASAN and fiber stack problem, thus if the stackSize is specified we're not detecting ASAN and probably will crash.
And thus it doesn't seem like a good idea to make it a user responsibility to detect ASAN.

Test Plan: tests

Reviewed By: andrii@fb.com

Subscribers: alikhtarov, folly-diffs@, yfeldblum, chalfant

FB internal diff: D2058741

Tasks: 7016680

Signature: t1:2058741:1431131082:9a41eb40d756c9c7af0632f7ecd55c17d10bb189
parent 4a92da5b
......@@ -17,18 +17,34 @@
#include <cassert>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/CPortability.h>
#include <folly/experimental/fibers/Baton.h>
#include <folly/experimental/fibers/Fiber.h>
#include <folly/experimental/fibers/Promise.h>
#include <folly/experimental/fibers/LoopController.h>
#include <folly/experimental/fibers/Promise.h>
#include <folly/futures/Try.h>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
namespace folly { namespace fibers {
namespace {
inline FiberManager::Options preprocessOptions(FiberManager::Options opts) {
#ifdef FOLLY_SANITIZE_ADDRESS
/* ASAN needs a lot of extra stack space.
16x is a conservative estimate, 8x also worked with tests
where it mattered. Note that overallocating here does not necessarily
increase RSS, since unused memory is pretty much free. */
opts.stackSize *= 16;
#endif
return opts;
}
} // anonymous
inline void FiberManager::ensureLoopScheduled() {
if (isLoopScheduled_) {
return;
......@@ -441,7 +457,7 @@ FiberManager::FiberManager(
std::unique_ptr<LoopController> loopController__,
Options options) :
loopController_(std::move(loopController__)),
options_(std::move(options)),
options_(preprocessOptions(std::move(options))),
exceptionCallback_([](std::exception_ptr eptr, std::string context) {
try {
std::rethrow_exception(eptr);
......
......@@ -61,15 +61,8 @@ class LocalType {
class FiberManager : public ::folly::Executor {
public:
struct Options {
#ifdef FOLLY_SANITIZE_ADDRESS
/* ASAN needs a lot of extra stack space.
16x is a conservative estimate, 8x also worked with tests
where it mattered. Note that overallocating here does not necessarily
increase RSS, since unused memory is pretty much free. */
static constexpr size_t kDefaultStackSize{16 * 16 * 1024};
#else
static constexpr size_t kDefaultStackSize{16 * 1024};
#endif
/**
* Maximum stack size for fibers which will be used for executing all the
* tasks.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment