- 26 Dec, 2013 3 commits
-
-
Jim Meyering authored
Summary: * folly/test/PackedSyncPtrTest.cpp: Avoid an operator new [] vs operator delete mismatch. Test Plan: fbconfig --platform-all=gcc-4.8.1-glibc-2.17 --sanitize=address \ folly/test:packed_sync_ptr_test && fbmake runtests Reviewed By: tudorb@fb.com FB internal diff: D1111227
-
Peter Griess authored
Summary: - Add autoconf check for cplus_demangle_v3_callback() in libiberty and avoid is usage when not available. Clang/libc++ on Mac OS X doesn't support this. Test Plan: - fbconfig -r folly && fbmake runtests - ./configure && make check on Mac OS X Reviewed By: tudorb@fb.com FB internal diff: D1108543
-
Hitesh Khandelwal authored
Summary: This reverts commit 2c4f8da739ba0294f2c947753a0e30fee291feb5. Test Plan: Compiles Reviewed By: tudorb@fb.com FB internal diff: D1108840
-
- 20 Dec, 2013 37 commits
-
-
Hitesh Khandelwal authored
Test Plan: Tested with subsequent thrift diff Reviewed By: davejwatson@fb.com FB internal diff: D1108428
-
Peter Griess authored
Summary: - Clang's libc++ doesn't provide these header files. Detect libc++ via the _LIBCPP_VERSION symbol (pulling it in by sourcing some header files earlier if necessary) and avoid using these files. - This is another attempt at D1074481. Test Plan: . Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D1074723
-
Peter Griess authored
Summary: - This fixes a bug introduced in D1002959 that broke -fb platform compilation: there was noone to forward-declare these symbols. Test Plan: - Built the gcc-4.8.1-glibc-2.17-fb platform - fbconfig -r folly && fbmake runtests - configure/make check on Mac OS X Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D1074720 Blame Revision: D1002959
-
Tudor Bosman authored
Test Plan: fbconfig -r folly/experimental/symbolizer folly/experimental/exception_tracer && fbmake runtests_opt Reviewed By: wez@fb.com FB internal diff: D1104426
-
Tudor Bosman authored
Summary: Yes, I know about boost::starts_with, but I think the convenience is worth it. Also, I've written then equivalent of removePrefix / removeSuffix way too many times. Test Plan: test added Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D1106425
-
Tudor Bosman authored
Summary: Even though it should be according to the docs; tdep_trace allocates memory on first use from each thread. Wrote a slow loop that we can use from the signal handler. The exception tracer still uses the fast version. Test Plan: fbconfig -r folly/experimental/symbolizer folly/experimental/exception_tracer && fbmake runtests_opt Reviewed By: philipp@fb.com FB internal diff: D1101095
-
Sarang Masti authored
Summary: Add futexTimedWait to Futex which allows callers to wait on the futex for a specified max duration. Test Plan: -- Ran all unitests Reviewed By: ngbronson@fb.com FB internal diff: D1090115
-
Nathan Bronson authored
Summary: AtomicStruct<T> acts like std::atomic<T>, but it supports any trivial or trivially-copyable type up to 8 bytes in size. I'm not sure why these types weren't included in the original std::atomic standard, since this construct removes a lot of boilerplate for some uses of std::atomic. Test Plan: 1. unit tests 2. this code is adapted from production use in tao/queues/LifoSem Reviewed By: davejwatson@fb.com FB internal diff: D1085106
-
Mark McDuff authored
Summary: folly::json::serialize by default doesn't check for valid UTF8, and as a result can generate invalid JSON. There is an option to check for valid UTF8, which throws on an error. This diff introduces a new option, `skip_invalid`, which replaces invalid chars with U+FFFD. http://en.wikipedia.org/wiki/Specials_(Unicode_block) seems to suggest that this is the correct replacement. @override-unit-failures Test Plan: g-unittest Reviewed By: delong.j@fb.com FB internal diff: D1102923
-
Andrew Gallagher authored
Summary: Adds LZMA2 and LZMA2_VARINT_SIZE compression support for folly::io::Compression. This format shows some big wins for compressing ELF object files and is useful in our modified ccache client. Test Plan: Compression unittests. Also, tested compressing object files built in fbcode. On average, the compression percentage improved from ~16.5% to ~12%. But we save a lot more as object files get bigger, which can help make bigger object files fit over fewer memcache keys. Reviewed By: njormrod@fb.com FB internal diff: D1092576
-
Tudor Bosman authored
Summary: ... even though Google's signal handler does it (https://code.google.com/p/google-glog/source/browse/trunk/src/signalhandler.cc?r=16#235) Assuming the existence of an invalid pthread_t is a lesser evil than reading from another thread's stack, IMO. Test Plan: folly/experimental/symbolizer/test Reviewed By: simpkins@fb.com FB internal diff: D1096620
-
Alex Malyshev authored
Summary: Makes clang nervous @override-unit-failures Test Plan: fbconfig -r folly && fbmake dbg succeeds Reviewed By: delong.j@fb.com FB internal diff: D1094209
-
Adam Simpkins authored
Summary: If a previous handler was found, the code was missing the step of actually re-raising the handler after restoring the old handler. Test Plan: Verified that our service actually exits after receiving SIGTERM. Reviewed By: tudorb@fb.com FB internal diff: D1096360
-
Tudor Bosman authored
Summary: We want to install the signal handler first and then give users an opportunity to add their callbacks. Test Plan: built Reviewed By: lucian@fb.com FB internal diff: D1092083 @override-unit-failures
-
Tudor Bosman authored
Summary: (not committing yet, but I want to trigger unittests) The glog symbolizer that we use has a few bugs (abort()s on certain small shared libraries) and doesn't allow us to distinguish between template specializations and function overloads (which, given that our code is more template-heavy than Google's, has in fact been an issue). Luckily, we have our own in folly, which doesn't have these problems and also supports mappings from address to file and line number. Switch translateFrames (aka the fb303 call that cpprof uses) to our symbolizer. Also, removed a lot of dead code in common/process. Test Plan: common/process, tested cpprof by hand Reviewed By: lucian@fb.com FB internal diff: D1090907 @override-unit-failures
-
Andrei Alexandrescu authored
Summary: SCOPE_SUCCESS may legitimately throw, so changed the `noexcept` attribute to a conditional one. Also added the noexcept promise to the lambdas in the hope the compiler will check code during compilation appropriately. (It currently doesn't.) Test Plan: Added a unittest that failed, not passes. Reviewed By: simpkins@fb.com FB internal diff: D1093328 @override-unit-failures
-
Nathan Bronson authored
Summary: The alignment requirements and details required to avoid false sharing belong in CacheLocality, so this diff moves them there. @override-unit-failures Test Plan: fbmake runtests Reviewed By: davejwatson@fb.com FB internal diff: D1086090
-
Nicholas Ormrod authored
Summary: D1090936 noticed some problems with fbstring iomanip behavior. The root cause is that os.write(ostream, char*, size_t) is an UnformattedOutputFunction, so disregards setw(), setfill(), and left/right alignment. The use of os.write instead of os << str.data() is intentional: D367009 switched from the latter to the former so that strings containing a '\0' are printed properly. There does not seem to be a public function to write with formatting. Where needed in libgcc, the function __ostream_insert is used. Since FBString already uses such 'private' functions, __ostream_insert is an appropriate solution. @override-unit-failures Test Plan: Added test cases to FBStringTest.cpp to cover iomanip. fbconfig -r folly && fbmake opt && fbmake runtests_opt Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D1091474
-
Tudor Bosman authored
Summary: Also, switch to the simpler unw_backtrace(), which has the nice advantage of actually doing IP adjustment (-1 in certain frames) correctly, unlike me :) This is in preparation for the faster backtrace in libunwind 1.1. Test Plan: folly/experimental/exception_tracer, folly/experimental/symbolizer, admarket/lib/util:memory_tracker_test Reviewed By: lucian@fb.com FB internal diff: D1088357
-
Nathan Bronson authored
Summary: CacheLocality reads cache sharing information from sysfs to determine how CPUs should be grouped to minimize contention, Getcpu provides fast access to the current CPU via __vdso_getcpu, and AccessSpreader uses these two to optimally spread accesses among a predetermined number of stripes. AccessSpreader<>::current(n) microbenchmarks at 22 nanos, which is substantially less than the cost of a cache miss. This means that we can effectively use it to reduce cache line ping-pong on striped data structures such as IndexedMemPool or statistics counters. Because CacheLocality looks at all of the cache levels, it can be used for different levels of optimization. AccessSpreader<>::stripeByChip.current() uses as few stripes as possible to avoid off-chip communication, AccessSpreader<>::stripeByCore.current() uses as many stripes as necessary to get the optimal speedup, but no more. @override-unit-failures Test Plan: new unit tests Reviewed By: davejwatson@fb.com FB internal diff: D1076718
-
Tudor Bosman authored
Summary: Per-thread caching calls malloc, which means it doesn't work for malloc's profiling (and also it isn't async-signal-safe, despite the documentation). Test Plan: compiled Reviewed By: philipp@fb.com FB internal diff: D1085368 @override-unit-failures
-
Tudor Bosman authored
Summary: Also, C++ify the interface and switch to per-thread caching in libunwind as per D1081259 Test Plan: folly/experimental/symbolizer/test Reviewed By: lucian@fb.com FB internal diff: D1081272
-
bsimmers authored
Summary: If the compare part of cmpxchg fails, it writes the unexpected value to %rax. At certain optimization levels this was causing me to hit an incorrectly failed assertion in some thrift code. I also cleaned up the asm statement to use named operands. Test Plan: Added new test that fails before this diff. Reviewed By: delong.j@fb.com FB internal diff: D1083222 @override-unit-failures
-
Adam Simpkins authored
Summary: Update IOBuf::gather() and RWCursor::gather() to check their arguments more carefully, and throw std::overflow_errors if the caller attempts to gather more data than is available. The comments for IOBuf::gather() claimed that it ensured that maxLength bytes would always be available when it returned. However, if the total chain length was less than maxLength, it would simply coalesce the full chain and return successfully, even though fewer than maxLength bytes were available. This fixes the code to throw a std::overflow_error rather than coalescing the chain. Additional, this updates RWCursor::gather() to ensure that it does not attempt to gather past the end of the IOBuf chain. Previously it could gather past the end of the chain, coalescing the head of the chain into the tail. This would free the IOBuf head, which was owned by an external caller. A new RWCursor::gatherAtMost() API is provided for callers that wish to gather as much as requested if possible, but still succeed if less than this is available. Test Plan: Updated the unit tests to test calling gather() with more bytes than actually available. Reviewed By: davejwatson@fb.com FB internal diff: D1081995
-
Adam Simpkins authored
Summary: My previous change to re-implement IOBuf's internal storage mechanism introduced a build failure when compiling with clang. This fixes the new compilation error in IOBuf.cpp, as well as two existing build failures in some of the unit tests. Test Plan: Built the folly/io code with clang. Reviewed By: andrewjcg@fb.com FB internal diff: D1082086
-
Adam Simpkins authored
Summary: This removes kFlagExt, and instead implements the internal buffer optimization using operator new and delete. IOBuf::createCombined() will allocate a single buffer for the IOBuf, SharedInfo, and the actual data itself. Each heap allocated IOBuf now contains a set of flags indicating if the memory segment indicating when it can actually be deleted. The delete operator won't actually free the storage until both the IOBuf and the data buffer are unused (the SharedInfo object always becomes unused at the same time as the data buffer). This has a couple advantages over the old mechanism: - Other IOBufs can continue to use and share the data storage space even after the original IOBuf associated with it is deleted. With the old internal buffer mechanism, internal buffers could never be shared. - This simplifies several parts of the code, since kFlagExt no longer exists. Code that previously required special handling for internal buffers no longer needs to be aware of them. One downside is that this can result in wasted space in some cases if the original IOBuf is changed to point at a different buffer, since the space for the data buffer cannot be freed until the IOBuf itself is also destroyed. The old internal buffer mechanism also had this problem, which we mitigated simply by disallowing internal buffers for larger than ~200 bytes. With the new mechanism we currently allocate an internal buffer for up to 1024 bytes by default, but we also allow callers to explicitly decide if they want an internal buffer or not. Test Plan: Added some new unit tests for the combined buffer behavior. Also ran all of the existing IOBuf unit tests, with and without ASAN. (ASAN performs additional memory checking, but also changes IOBuf's behavior slightly as usingJEMalloc() is false with ASAN.) Reviewed By: davejwatson@fb.com FB internal diff: D1072336 @override-unit-failures
-
Tudor Bosman authored
Summary: Because the global cache is slow and contends on locks. Test Plan: testinproduction Reviewed By: philipp@fb.com FB internal diff: D1081259
-
Soren Lassen authored
Summary: It's convenient to get back the fd, similar to unique_ptr::release(). Test Plan: unittest Reviewed By: tudorb@fb.com FB internal diff: D1080426
-
Tudor Bosman authored
Test Plan: test added Reviewed By: lucian@fb.com FB internal diff: D1076170 @override-unit-failures
-
Tudor Bosman authored
Summary: To be used in the new fatal signal handler. Test Plan: test added Reviewed By: lucian@fb.com FB internal diff: D1076169 @override-unit-failures
-
Tudor Bosman authored
Summary: To be used from the (new) fatal signal handler. Test Plan: test added Reviewed By: lucian@fb.com FB internal diff: D1076168 @override-unit-failures
-
Adam Simpkins authored
Summary: Improve moveToFbString()'s code which determines if we actually have a buffer that was allocated with malloc(). The old code simply checked if flags_ == kFlagExt. This check is rather fragile, and relies on very specific behavior from the existing construction methods. It also unnecessarily forced reallocation in some cases. This updates the code to have more specific checks for the flags and fields that actually matter. In particular, even if we have an external buffer, if sharedInfo->freeFn is set then it is not managed by malloc(). The old check happened to work because takeOwnership() was the only function that set set freeFn, and it also set kFlagFreeSharedInfo. This also improves the code so that it won't unnecessarily reallocate the buffer if kFlagMaybeShared is set but the buffer isn't really shared. The code will also no longer unnecessarily reallocates the buffer just because kFlagFreeSharedInfo is set. Test Plan: Updated the moveToFbString() test to also test with buffers created using takeOwnership() and wrapBuffer(). Reviewed By: davejwatson@fb.com FB internal diff: D1072304 @override-unit-failures
-
Adam Simpkins authored
Summary: The IOBuf::reserveSlow() code assumed that external buffers were always allocated with malloc. This would cause problems when if reserve() was ever used on a buffer created with IOBuf::takeOwnership(). This changes the code to now check if a user-specified free function has been supplied. If so, then it does not try to use realloc()/rallocm(), and it now frees the old buffer using the specified free function rather than free(). User-supplied buffers also have a separately allocated SharedInfo object, which must be freed when we no longer need it. Test Plan: Added additional unit tests to check calling reserve() on IOBufs created with IOBuf::takeOwnership(). Reviewed By: davejwatson@fb.com FB internal diff: D1072292
-
Anton Likhtarov authored
Summary: A dumb&slow implementation. I just needed something that outputs keys in a sorted order. No easy to use API to discourage the use due to perf implications. Test Plan: unit test Reviewed By: delong.j@fb.com FB internal diff: D1073757
-
Brian Watling authored
Summary: Rename the 'capacity' argument so g++ will not complain when -Wshadow is enabled ('capacity' is also a method on MPMCQueue) Test Plan: compiles, unit tests pass Reviewed By: ngbronson@fb.com FB internal diff: D1076220
-
Soren Lassen authored
Test Plan: unittest Reviewed By: tudorb@fb.com FB internal diff: D1071715
-
Adam Simpkins authored
Summary: The IOBuf.StringOperations test contained two buggy tests. According to the comments, they were intended to test a string spanning multiple buffers. They created a chain of two buffers, but used Appender to write the string, which only writes in the final buffer in the chain. Additionally, the test didn't request enough space in the final buffer for the string data, and didn't allow Appender to grow the buffer. (The code also didn't check the return value from pushAtMost() to see if it actually wrote all of the string data.) The test only passed because IOBuf would normally allocate more capacity than the caller requested. I fixed the tests to request sufficient capacity for the string data, and use push() rather than pushAtMost() to ensure that all data was written correctly. I also added two new tests which actually test with strings spanning multiple buffers. Test Plan: Ran this test with some changes to IOBuf that cause it to only allocate the requested capacity in some cases, and verified that the StringOperations test pass now. (The changes I was testing with use goodMallocSize() to determine the allocation size even for small internal buffers. When not using jemalloc, goodMallocSize() returns the original size, so it only allocates the capacity requested by the caller.) Reviewed By: pgriess@fb.com FB internal diff: D1072283
-