facebook / folly Goto Github PK
View Code? Open in Web Editor NEWAn open-source C++ library developed and used at Facebook.
Home Page: https://groups.google.com/forum/?fromgroups#!forum/facebook-folly
License: Apache License 2.0
An open-source C++ library developed and used at Facebook.
Home Page: https://groups.google.com/forum/?fromgroups#!forum/facebook-folly
License: Apache License 2.0
The following simple program will produce error under libc++:
#include <cassert>
#include <string>
#include <unordered_map>
using namespace std;
namespace std {
template <class C>
struct hash<std::basic_string<C> > : private hash<const C*> {
size_t operator()(const std::basic_string<C> & s) const {
return hash<const C*>::operator()(s.c_str());
}
};
}
const static unordered_map<string, int> m = {
{"abc", 1},
{"xyz", 2},
};
int main() {
assert(m.find("abc") != m.end());
}
String.h shouldn't specialize hash function for libc++.
Hey,
This is the log of the test suite from running "make check" on a fresh clone following the instructions of the README:
====================================
folly 3.2: test/test-suite.log
====================================
# TOTAL: 36
# PASS: 35
# SKIP: 0
# XFAIL: 0
# FAIL: 1
# XPASS: 0
# ERROR: 0
.. contents:: :depth: 2
FAIL: foreach_test
==================
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from Foreach
[ RUN ] Foreach.ForEachRvalue
[ OK ] Foreach.ForEachRvalue (0 ms)
[ RUN ] Foreach.ForEachKV
[ OK ] Foreach.ForEachKV (0 ms)
[ RUN ] Foreach.ForEachKVBreak
[ OK ] Foreach.ForEachKVBreak (0 ms)
[ RUN ] Foreach.ForEachKvWithMultiMap
[ OK ] Foreach.ForEachKvWithMultiMap (0 ms)
[ RUN ] Foreach.ForEachEnumerate
[ OK ] Foreach.ForEachEnumerate (0 ms)
[ RUN ] Foreach.ForEachEnumerateBreak
[ OK ] Foreach.ForEachEnumerateBreak (0 ms)
[ RUN ] Foreach.ForEachRangeR
[ OK ] Foreach.ForEachRangeR (0 ms)
[----------] 7 tests from Foreach (0 ms total)
[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (0 ms total)
[ PASSED ] 7 tests.
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0907 03:02:39.205322 1549 Benchmark.cpp:210] Check failed: 1 == ts.tv_nsec (1 vs. 4000000) Clock too coarse, upgrade your kernel.
*** Check failure stack trace: ***
I got this on a Microsoft Azure cloud compute server with the most up-to-date Linux kernel that is not RC:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
3.16.2-031602-generic
Hope I'm not just being dumb. Looks like I was still able to run sudo make install
without any problems.
[root@localhost folly]# make check
Making check in .
make[1]: Entering directory `/root/folly/folly'
make[1]: Leaving directory `/root/folly/folly'
Making check in test
make[1]: Entering directory `/root/folly/folly/test'
Making check in .
make[2]: Entering directory `/root/folly/folly/test'
make libgtestmain.la libgtest.la benchmark_test concurrent_skiplist_benchmark sorted_vector_types_test foreach_test hash_test timeout_queue_test conv_test range_test bits_test bit_iterator_test small_locks_test packed_sync_ptr_test small_vector_test discriminated_ptr_test fbstring_test_using_jemalloc thread_cached_int_test thread_local_test fbvector_test dynamic_test json_test scope_guard_test endian_test rw_spinlock_test synchronized_test concurrent_skiplist_test histogram_test group_varint_test map_util_test string_test producer_consumer_queue_test atomic_hash_array_test atomic_hash_map_test format_test fingerprint_test portability_test cpuid_test spooky_hash_v1_test spooky_hash_v2_test
make[3]: Entering directory `/root/folly/folly/test'
make[3]: *** No rule to make target `gtest-1.6.0/src/gtest-all.cc', needed by `gtest-1.6.0/src/libgtestmain_la-gtest-all.lo'. Stop.
make[3]: Leaving directory `/root/folly/folly/test'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/root/folly/folly/test'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/root/folly/folly/test'
make: *** [check-recursive] Error 1
Centos 7 throws up the error:
These are installed:
yum -y install gcc gcc-c++ autoconf autoconf-archive automake boost-devel libtool lz4-devel lzma-devel snappy-devel zlib-devel glog-devel scons libtool gtest-devel
Built gflags, double-conversion and lzma.
What do I need to make this pass?
Allow folly to build and work on windows systems - using
This is necessary to allow hhvm to link and use folly
Visual Studio 2013 is missing several c++11 features which folly uses, which will make porting a bit of a pain. Currently these have been identified as:
In addition windows in general is missing several posix apis in use. However, only very platform specific futex and elf/dwarf features do not have analogs in the windows apis. So these can be "faked" with posix api wrappers, and perhaps later with pluggable direct calls into windows apis. Even the futex use could be replaced with some of the new threading and atomic calls available since windows 7.
All the currently in use dependencies compile and work properly on windows
This will necessitate a friendlier build system (that's preferably a bit more up to date than the current autotools system), builds of dependencies for deps that don't distribute pre-build binaries (should always be sure that runtimes match), fixes for c++11 features not implemented in msvc, and posix wrappers/adjustments for platform dependent implementations for folly features.
Folly uses two external libs during the build: double-conversion and gtest. The installation instructions suggest to download the sources and build by itself.
But there are systems with great package managers (basically any Linux distro) that most likely have these libraries in their packages. Linux Arch for example has both these libs. It would be great if build system was able to use the system dependencies if they are already installed.
I am interested in leveraging folly/io/, folly/io/async/, and some code in thrift/lib/cpp/src/thrift/. Do you have any advice on how to approach this?
For example, I'd like to create a simple UDP server and parse / process the above-L4 protocol myself while leveraging the L4 / async / socket code in these libraries. I am not sure I can (or should, or want to) express this protocol in the Thrift IDL.
Thrift has some of this socket server code, and also chromium/src/net/udp & associated chromium code, but ultimately I think it would be great if this was provided in folly. I see some potentially useful socket code in folly/test/SocketAddressTest.cpp.
Thank you!
$ clang --version
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
folly/FBString.h:936:8: error: too few template arguments for class template 'basic_string'
std::basic_string<Char> backend_;
^
folly/Traits.h:243:9: note: template is declared here
class basic_string;
^
folly/FBString.h:2315:8: error: no member named '__ostream_insert' in namespace 'std'
std::__ostream_insert(os, str.data(), str.size());
~~~~~^
folly/Range.h:42:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>
^
$ locate c++config.h
/usr/include/c++/4.2.1/bits/c++config.h
This file needs checking in to folly/m4
http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
On OSX, I had to change MAP_ANONYMOUS to MAP_ANON to get folly to build (line 160 in MemoryMapping.cpp ).
Thanks,
Yacine
In file included from Bits.cpp:17:
In file included from ./../folly/Bits.h:58:
In file included from ./../folly/Portability.h:191:
./../folly/detail/FunctionalExcept.h:22:1: error: unknown type name '_LIBCPP_BEGIN_NAMESPACE_STD'
FOLLY_NAMESPACE_STD_BEGIN
Obviously _LIBCPP_BEGIN_NAMESPACE_STD is not recognized. One needs to include any standard header to get the definition of _LIBCPP_BEGIN_NAMESPACE_STD. Or include <__config>.
From the double conversion library into the /usr/local/include/folly folder: double-conversion.h utils.h
Also /usr/local/include/folly/Preprocessor.h was missing, I copied it there from the source directory.
(also, the README suggests that the LDFLAGS and CPPFLAGS variables should be altered in the terminal session, but that didn't work for me, so I copied the lines into the configure.ac file right after the "checks for header files" comment)
I'm on OpenSuse 12.1 64bit, gcc 4.7. Might be a local problem from my side.
Hi,
we have an older version of folly running (how do I check the version number?) and I tried compiling the newest version available but I was stuck on some boost-library issue in configure. [A step by step introduction how to get folly running and tests started would be very helpful btw.]
Anyway, the following code crashes at the foobar line in our version.
Could you check whether this is fixed already?
(sorry, that this is not with google test)
BOOST_AUTO_TEST_CASE( test_folly_fbvector_test )
{
// using a std::vector instead of fbvector will work
folly::fbvector<std::map<std::string, std::string>> vec_of_maps;
vec_of_maps.push_back(std::map<std::string, std::string>());
vec_of_maps.push_back(std::map<std::string, std::string>());
BOOST_CHECK(vec_of_maps.size() == 2);
// inserting into the second map works
vec_of_maps[1]["hello"] = "world";
BOOST_CHECK(vec_of_maps[0].size() == 0);
BOOST_CHECK(vec_of_maps[1].size() == 1);
// inserting into first map should work (but crashes)
vec_of_maps[0]["foo"] = "bar";
BOOST_CHECK(vec_of_maps[0].size() == 1);
BOOST_CHECK(vec_of_maps[1].size() == 1);
}
I wonder where is the header file.
Is there a reason why AtomicHashMap supports only stateless allocators? It seems like an oversight, as It would be convenient to be able to support stateful allocation for containers stored in shared memory.
folly contains a decent amount of gcc'isms. Let me enumerate some of them:
configure.ac has an incorrect build path:
AC_SUBST(AM_CPPFLAGS, '-I../$(top_srcdir)'" "'-I$(top_srcdir)/io'" "'-I$(top_srcdir)/test'" -lstdc++ $CXX_FLAGS $BOOST_CPPFLAGS")
Should be:
AC_SUBST(AM_CPPFLAGS, '-I$(top_srcdir)/..'" "'-I$(top_srcdir)/io'" "'-I$(top_srcdir)/test'" -lstdc++ $CXX_FLAGS $BOOST_CPPFLAGS")
Currently there are some non-portable items that breaks the build in HHVM, Just wondering the possibility of the Mac OS X fix and the PR you intend to receive.
Thanks!
In file included from /Volumes/ramdisk/hhvm/third-party/folly/folly/Baton.h:26:0,
from /Volumes/ramdisk/hhvm/third-party/folly/folly/LifoSem.h:28,
from /Volumes/ramdisk/hhvm/third-party/folly/folly/experimental/wangle/concurrent/LifoSemMPMCQueue.h:19,
from /Volumes/ramdisk/hhvm/third-party/folly/folly/experimental/wangle/concurrent/ThreadPoolExecutor.h:19,
from /Volumes/ramdisk/hhvm/third-party/folly/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h:18,
from /Volumes/ramdisk/hhvm/third-party/folly/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp:17:
/Volumes/ramdisk/hhvm/third-party/folly/folly/detail/Futex.h:24:25: fatal error: linux/futex.h: No such file or directory
#include <linux/futex.h>
^
compilation terminated.
make[2]: *** [third-party/folly/CMakeFiles/folly.dir/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp.o] Error 1
make[1]: *** [third-party/folly/CMakeFiles/folly.dir/all] Error 2
I just updated double-conversion. Normally, the custom SConstruct file should not be necessary anymore. If you see issues, please open a bug.
g++ -DHAVE_CONFIG_H -I. -I../. -I./io -I./test -lstdc++ -std=gnu++0x -pthread -I/usr/include -I/home/preilly/double-conversion/src/ -lboost_thread-mt -lboost_system -g -O2 -MT GenerateFingerprintTables.o -MD -MP -MF .deps/GenerateFingerprintTables.Tpo -c -o GenerateFingerprintTables.o test -f 'build/GenerateFingerprintTables.cpp' || echo './'
build/GenerateFingerprintTables.cpp
mv -f .deps/GenerateFingerprintTables.Tpo .deps/GenerateFingerprintTables.Po
/bin/sh ./libtool --tag=CXX --mode=link g++ -lboost_thread-mt -lboost_system -g -O2 -L/home/preilly/double-conversion/ -o generate_fingerprint_tables GenerateFingerprintTables.o libfolly.la -ldouble_conversion_pic -lgflags -lglog
libtool: link: g++ -g -O2 -o .libs/generate_fingerprint_tables GenerateFingerprintTables.o -L/home/preilly/double-conversion/ ./.libs/libfolly.so -lboost_system -lboost_thread-mt -lpthread -ldouble_conversion_pic /usr/lib64/libgflags.so -lglog -pthread -Wl,-rpath -Wl,/usr/local/lib
./.libs/libfolly.so: undefined reference to boost::system::system_category()' ./.libs/libfolly.so: undefined reference to
boost::system::generic_category()'
collect2: error: ld returned 1 exit status
make[2]: *** [generate_fingerprint_tables] Error 1
make[2]: Leaving directory /home/preilly/folly/folly' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/home/preilly/folly/folly'
make: *** [all] Error 2
https://github.com/facebook/folly/blob/master/folly/Malloc.cpp#L36
uint64_t is un-declared symbol. Need to include cstdint.
/usr/local/Cellar/hhvm/3.2.1b/src/third-party/folly/folly/FBString.h:911:8: error: too few template arguments for class template 'basic_string'
std::basic_string<Char> backend_;
^
/usr/local/Cellar/hhvm/3.2.1b/src/third-party/folly/folly/Traits.h:244:9: note: template is declared here
class basic_string;
^
Configure fails to find the double-conversion.h header, which the Gentoo science overlay package installed into /usr/include/double-conversion. So if I add CPPFLAGS=-I/usr/include/double-conversion then it finds it but then fails on this error:
checking for ceil in -ldouble_conversion_pic... no
presumably because there is no pic library, just a non-pic library.
Is that a bug in Gentoo's package or in folly's configure? Thanks, cheers.
It seems to me that folly::benchmarks (the vector) is subject to static initialisation order fiasco.
All my tests are constructed, "adding them" to benchmarks, and then benchmarks is initialised :(
gcc version 4.8.2 20140206
OS: Linux nova 3.13.7-1-ARCH
When including the following header in my code
I am getting a warning below. What's the proper way of getting rid of it aside from defining no-deprecated compilation option?
In file included from /usr/include/c++/4.8.2/ext/hash_set:60:0,
from /opt/env/prod/Folly/Current/include/folly/FBString.h:101,
from /opt/env/prod/Folly/Current/include/folly/Conv.h:27,
from /opt/env/prod/Folly/Current/include/folly/Exception.h:26,
from /opt/env/prod/Folly/Current/include/folly/detail/ThreadLocalDetail.h:30,
from /opt/env/prod/Folly/Current/include/folly/ThreadLocal.h:53,
from /opt/env/prod/Folly/Current/include/folly/ThreadCachedInt.h:31,
from /opt/env/prod/Folly/Current/include/folly/AtomicHashArray.h:41,
from /opt/env/prod/Folly/Current/include/folly/AtomicHashMap.h:93,
...
/usr/include/c++/4.8.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
#warning
^
It seems the effort to port Bits.h to MSVC have a little bit problem:
__builtin_ffs(x) won't return 0 when x is not 0, but _BitScanForward(index, mask) can load index to zero when mask's LSB is 1.
I make this:
#ifdef _MSC_VER
unsigned long index;
return (_BitScanForward(&index, x) ? index + 1 : 0);
#else
return __builtin_ffs(x);
#endif
[ 11%] Building CXX object third-party/folly/CMakeFiles/folly.dir/folly/io/async/EventBase.cpp.o
In file included from /Users/ccarnell/Sites/hhvm/third-party/folly/folly/io/async/EventBase.cpp:23:0:
/Users/ccarnell/Sites/hhvm/third-party/folly/folly/ThreadName.h:25:42: error: missing binary operator before token "("
#if (defined(__GLIBC__) && __GLIBC_PREREQ(2, 12))
^
In file included from /Users/ccarnell/Sites/hhvm/third-party/folly/folly/io/async/NotificationQueue.h:23:0,
from /Users/ccarnell/Sites/hhvm/third-party/folly/folly/io/async/EventBase.cpp:24:
/Users/ccarnell/Sites/hhvm/third-party/folly/folly/io/async/EventFDWrapper.h:24:22: fatal error: features.h: No such file or directory
#include <features.h>
^
compilation terminated.
make[2]: *** [third-party/folly/CMakeFiles/folly.dir/folly/io/async/EventBase.cpp.o] Error 1
make[1]: *** [third-party/folly/CMakeFiles/folly.dir/all] Error 2
make: *** [all] Error 2
Compiling HHVM:
[ 8%] Building CXX object third-party/folly/CMakeFiles/folly.dir/folly/Version.cpp.o
In file included from /Users/ccarnell/Sites/hhvm/third-party/folly/folly/Version.cpp:17:0:
/Users/ccarnell/Sites/hhvm/third-party/folly/folly/VersionCheck.h:78:55: error: constructor priorities are not supported
__attribute__((constructor(101))) void versionCheck() { \
^
/Users/ccarnell/Sites/hhvm/third-party/folly/folly/Version.cpp:21:1: note: in expansion of macro 'FOLLY_VERSION_CHECK'
FOLLY_VERSION_CHECK(folly, FOLLY_VERSION)
^
make[2]: *** [third-party/folly/CMakeFiles/folly.dir/folly/Version.cpp.o] Error 1
make[1]: *** [third-party/folly/CMakeFiles/folly.dir/all] Error 2
make: *** [all] Error 2
https://github.com/facebook/folly/blob/master/folly/Malloc.h#L175
https://github.com/facebook/folly/blob/master/folly/FBString.h#L304
https://github.com/facebook/folly/blob/master/folly/Malloc.h#L165
https://github.com/facebook/folly/blob/master/folly/Malloc.h#L181 -> this might return NULL and you'll lose whatever pointer it gets assigned to.
thpp links against both folly and fbthrift. With the addition of Codel to folly, both libraries define codel_interval and codel_target_delay in the top-level namespace. This name collision prevents thpp from building successfully.
I got thpp to build by removing Codel from folly and re-building both.
/tmp/hhvm-HZiR/hhvm-HHVM-2.3.2/hphp/third_party/folly/folly/Checksum.cpp: In function 'uint32_t folly::detail::crc32c_hw(const uint8_t*, size_t, uint32_t)':
/tmp/hhvm-HZiR/hhvm-HHVM-2.3.2/hphp/third_party/folly/folly/Checksum.cpp:42:63: error: '__builtin_ia32_crc32qi' was not declared in this scope
sum = (uint32_t)__builtin_ia32_crc32qi(sum, data[offset]);
^
/tmp/hhvm-HZiR/hhvm-HHVM-2.3.2/hphp/third_party/folly/folly/Checksum.cpp:50:43: error: '__builtin_ia32_crc32di' was not declared in this scope
sum = __builtin_ia32_crc32di(sum, *src);
^
/tmp/hhvm-HZiR/hhvm-HHVM-2.3.2/hphp/third_party/folly/folly/Checksum.cpp:56:61: error: '__builtin_ia32_crc32qi' was not declared in this scope
sum = (uint32_t)__builtin_ia32_crc32qi(sum, data[offset]);
^
[ 3%] Building C object hphp/third_party/libmbfl/mbfl/CMakeFiles/mbfl.dir/__/filters/mbfilter_jis.c.o
[ 3%] Building C object hphp/third_party/timelib/CMakeFiles/timelib.dir/dow.c.o
make[2]: *** [hphp/third_party/folly/CMakeFiles/folly.dir/folly/Checksum.cpp.o] Error 1
make[1]: *** [hphp/third_party/folly/CMakeFiles/folly.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
This is more of a housekeeping suggestion than anything else, but it may be useful to people trying to utilize the library is the existing contents of the /folly/docs folder were put into the Github wiki for this project. It may not be readily apparent to people new to the library where to find the documentation, and they may miss the /folly/docs folder during a search for it. It's not a high-importance suggestion, just an idea for making the understanding and immediate use of folly easier.
Traits.h defines classes std::{pair,basic_string,vector,deque,list,set,map,shared_ptr}, however when compiling HHVM on OS X 10.9 (using clang and libc++) this results in conflicts à la:
In file included from hphp.y:11:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/compiler/parser/parser.h:23:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/runtime/base/exceptions.h:25:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/String.h:34:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Conv.h:27:
/Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/FBString.h:911:8: error: too few template arguments for class template 'basic_string'
std::basic_string<Char> backend_;
^
/Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Traits.h:245:9: note: template is declared here
class basic_string;
^
In file included from hphp.y:11:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/compiler/parser/parser.h:23:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/runtime/base/exceptions.h:25:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/String.h:34:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Conv.h:30:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Range.h:28:
/usr/local/include/glog/logging.h:1193:19: error: too few template arguments for class template 'vector'
std::vector<std::string>* outvec);
^
/Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Traits.h:251:9: note: template is declared here
class vector;
^
In file included from hphp.y:11:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/compiler/parser/parser.h:23:
In file included from /Users/mcuelenaere/Projects/hhvm/hphp/runtime/base/exceptions.h:25:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/String.h:34:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Conv.h:30:
In file included from /Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Range.h:28:
/usr/local/include/glog/logging.h:1433:33: error: too few template arguments for class template 'vector'
GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
^
/Users/mcuelenaere/Projects/hhvm/third-party/folly/folly/Traits.h:251:9: note: template is declared here
class vector;
^
I hackfixed these with this diff:
iff --git a/folly/Traits.h b/folly/Traits.h
index 2b94df1..eaed2c3 100644
--- a/folly/Traits.h
+++ b/folly/Traits.h
@@ -235,6 +235,7 @@ template <class T> struct IsZeroInitializable
* although that is not guaranteed by the standard.
*/
+#if 0
FOLLY_NAMESPACE_STD_BEGIN
template <class T, class U>
@@ -260,6 +261,16 @@ template <class T>
class shared_ptr;
FOLLY_NAMESPACE_STD_END
+#else
+#include <utility>
+#include <string>
+#include <vector>
+#include <deque>
+#include <list>
+#include <set>
+#include <map>
+#include <memory>
+#endif
namespace boost {
however, I'm unsure if this is the right approach.
Sorry, I am a new beginner of Folly.
But I want to know what folly can do? but right now, no wiki page for this common issue.
Thanks
Longda
As per title, when building against Boost 1.53
According to http://www.isthe.com/chongo/tech/comp/fnv/, in Hash.h,
const uint32_t FNV_32_HASH_START = 216613626UL;
should be
const uint32_t FNV_32_HASH_START = 2166136261UL;
This may or may not have an averse affect on the quality of the FNV hashes.
The unit tests for this also need to be fixed as they also account for the wrong value--2 wrongs make a right :)
In AsyncIO
property pending_
has type ssize_t
, but pending()
returns size_t
. Its normal?
Can you tag releases so they are easier to lock in place?
https://github.com/facebook/folly/blob/master/folly/Random-inl.h#L108
According to cppreference: http://en.cppreference.com/w/cpp/numeric/random/seed_seq
seed_seq is not copy-constructible, therefore causing compiling error.
It seams like if another library is included before folly/Traits.h (which gets included from all over folly) that has any kind of use of boost::has_nothrow_constructor on basic types (std::shared_ptr, boost::shared_ptr, others) the folly FOLLY_ASSUME_FBVECTOR_COMPATIBLE_* macros end up producing errors.
More detail:
It seams like if there is a use templated use of a std::shared_ptr or that depends on not fully defined type (see bellow with External) then folly will blow up. In my case I have an external library that uses std::shared_ptr and it hides SomeType due to the PIMPL idiom.
Reduced test case:
#include <string>
#include <memory>
// Some other header would do this
#include <boost/type_traits.hpp>
struct External;
template <typename T>
class Check : public boost::has_nothrow_constructor<T>
{ };
static_assert(Check<std::shared_ptr<External>>::value, "txt");
// Then we include folly
#include <folly/Traits.h>
int main(int argc, char* argv[])
{
return 0;
}
Compilation error
In file included from test2.cpp:18:0:
/usr/local/include/folly/Traits.h:448:1: error: partial specialization of ‘boost::has_nothrow_constructor<std::shared_ptr<_Tp1> >’ after instantiation of ‘boost::has_nothrow_constructor<std::shared_ptr<External> >’ [-fpermissive]
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(std::shared_ptr);
^
EDIT: There was another unrelated issue in this ticket. I fixed it... but the original problem still remains.
This error shows up only when attempting to statically link a binary with folly.
This is due to a bug in configure.ac
Below is the fix:
-AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT], [test "$ac_cv_header_bits_functexcept" = "yes"])
+AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT], [test "$ac_cv_header_bits_functexcept_h" = "yes"])
Configure fails to find the double-conversion.h header, which the Gentoo science overlay package installed into /usr/include/double-conversion. So if I add CPPFLAGS=-I/usr/include/double-conversion then it finds it but then fails on this error:
checking for ceil in -ldouble_conversion_pic... no
presumably because there is no pic library, just a non-pic library.
Is that a bug in Gentoo's package or in folly's configure? Thanks, cheers.
I tried to change crashOnError
to above public type, but cannot build source successes.
Fomatter{
private:
bool crashOnError_{true};
public:
...
};
Thus, Source retrieve to old state of source code. An error show as below:
In file included from /usr/include/c++/4.6/ext/hash_set:61:0,
from .././folly/String.h:25,
from .././folly/Format.h:36,
from .././folly/dynamic-inl.h:25,
from .././folly/dynamic.h:522,
from json.h:44,
from Benchmark.cpp:21:
/usr/include/c++/4.6/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
In file included from .././folly/dynamic-inl.h:25:0,
from .././folly/dynamic.h:522,
from json.h:44,
from Benchmark.cpp:21:
.././folly/Format.h:159:8: error: function definition does not declare parameters
.././folly/Format.h: In member function 'void folly::Formatter<containerMode, Args>::setCrashOnError(bool)':
.././folly/Format.h:76:5: error: 'crashOnError_' was not declared in this scope
In file included from .././folly/Format.h:358:0,
from .././folly/dynamic-inl.h:25,
from .././folly/dynamic.h:522,
from json.h:44,
from Benchmark.cpp:21:
.././folly/Format-inl.h: In member function 'void folly::Formatter<containerMode, Args>::handleFormatStrError() const':
.././folly/Format-inl.h:152:7: error: 'crashOnError_' was not declared in this scope
https://github.com/facebook/folly/blob/master/folly/wangle/Executor.h#L66
The type logic_error is not recognized. Obviously there is a missing header stdexcept.
Here is a list of typos, i found in your code:
facebook-folly-27494a2/folly/AtomicHashArray-inl.h:255: noticably ==> noticeably
facebook-folly-27494a2/folly/README:21: enviroment ==> environment
facebook-folly-27494a2/folly/PackedSyncPtr.h:108: Syncronization ==> Synchronization
facebook-folly-27494a2/folly/ConcurrentSkipList.h:256: everytime ==> every time
facebook-folly-27494a2/folly/FBString.h:1487: occurences ==> occurrences
facebook-folly-27494a2/folly/FBString.h:2227: compatiblity ==> compatibility
facebook-folly-27494a2/folly/test/PackedSyncPtrTest.cpp:114: succesfully ==> successfully
facebook-folly-27494a2/folly/test/ConcurrentSkipListBenchmark.cpp:582: multi-thread ==> multithread
facebook-folly-27494a2/folly/test/ThreadCachedIntTest.cpp:158: Acheives ==> Achieves
facebook-folly-27494a2/folly/docs/AtomicHashMap.md:29: syncronization ==> synchronization
Best regards
Ettl Martin
After 79c25e6 folly can no longer compile on OS X.
Fails with detail/Futex.h:24:25: fatal error: linux/futex.h: No such file or directory
.
Prior to 79c25e6 it would compile.
Reproduce (tested on 10.9.2 but should fail on others too).
Dependencies (if you don't have them)
brew install boost glog gflags jemalloc scons cmake autoconf automake libtool gcc49
git clone https://code.google.com/p/double-conversion/
cd double-conversion/
cmake .
make
make install
Folly:
git clone https://github.com/facebook/folly.git folly
cd folly/folly/test
wget http://googletest.googlecode.com/files/gtest-1.6.0.zip
unzip gtest-1.6.0.zip
cd ../
autoreconf --install
CXX="/usr/local/bin/g++-4.9" CC="/usr/local/bin/gcc-4.9" ./configure
make
Error:
libtool: compile: /usr/local/bin/g++-4.9 -DHAVE_CONFIG_H -I../. -I./io -I./test -pthread -I/usr/local/include -std=gnu++0x -g -O2 -MT json.lo -MD -MP -MF .deps/json.Tpo -c json.cpp -o json.o >/dev/null 2>&1
mv -f .deps/json.Tpo .deps/json.Plo
/bin/sh ./libtool --tag=CXX --mode=compile /usr/local/bin/g++-4.9 -DHAVE_CONFIG_H -I../. -I./io -I./test -pthread -I/usr/local/include -std=gnu++0x -g -O2 -MT MemoryIdler.lo -MD -MP -MF .deps/MemoryIdler.Tpo -c -o MemoryIdler.lo `test -f 'detail/MemoryIdler.cpp' || echo './'`detail/MemoryIdler.cpp
libtool: compile: /usr/local/bin/g++-4.9 -DHAVE_CONFIG_H -I../. -I./io -I./test -pthread -I/usr/local/include -std=gnu++0x -g -O2 -MT MemoryIdler.lo -MD -MP -MF .deps/MemoryIdler.Tpo -c detail/MemoryIdler.cpp -fno-common -DPIC -o .libs/MemoryIdler.o
In file included from detail/MemoryIdler.h:25:0,
from detail/MemoryIdler.cpp:17:
detail/Futex.h:24:25: fatal error: linux/futex.h: No such file or directory
#include <linux/futex.h>
^
compilation terminated.
make[2]: *** [MemoryIdler.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Checking out 6d89f3d resolves the above compile issue, and with a few additional fixes (https://gist.github.com/duedal/7887803) the entire lib can compile.
Linking CXX executable gen-infotabs
Linking CXX executable gen-class-map
Undefined symbols for architecture x86_64:
Undefined symbols for architecture x86_64:
"std::__throw_logic_error(char const*)", referenced from:
"std::__throw_logic_error(char const*)", referenced from:
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, std::__1::allocator<char> const&) in gen-class-map.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, std::__1::allocator<char> const&) in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, std::__1::allocator<char> const&) in libfolly.a(Demangle.cpp.o)
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, std::__1::allocator<char> const&) in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::basic_fbstring(char const*, std::__1::allocator<char> const&) in libfolly.a(Demangle.cpp.o)
"std::__throw_out_of_range(char const*)", referenced from:
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in gen-infotabs.cpp.o
"std::__throw_out_of_range(char const*)", referenced from:
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::substr(unsigned long, unsigned long) const in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in gen-class-map.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::substr(unsigned long, unsigned long) const in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in idl.cpp.o
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in libfolly.a(json.cpp.o)
folly::basic_fbstring<char, std::__1::char_traits<char>, std::__1::allocator<char>, folly::fbstring_core<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const in libfolly.a(json.cpp.o)
ld: symbol(s) not found for architecture x86_64
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)clang: error
: linker command failed with exit code 1 (use -v to see invocation)
The comment at FBString.h:74 references an absolute path to
/home/engshare/third-party/src/libgcc/libgcc-4.6.2/gcc-4.6.2-20111027/libstdc++-v3/include/bits/basic_string.h
for further information.
From the "FBVector.md" page I would like to add more comment then an "issue".
Now since the focus is on "performance" a few key things need to be pointed out about "std::vector"
or any similar implementation. For that matter any kind of memory container.
To get real performance out of any program you need to know what is going on "under the hood".
At least for key parts like an STL containers.
Programmers of any language just thinking in terms of high level abstractions, thinking in ways of just
"this is how it' done", this is what my teacher, or my CS text book says, etc., just dropping things here and there
are never really going to get real performance unless it happens by accident.
Not to mention suffer from other evils like code bloat to some degree or another.
Performance is particularly important for real time applications like games, simulations, etc.
And really wouldn't we all like better performing day to day applications and tools that we use all the time?
Read Pete Isensee articles where he breaks down a lot of STL use in game development.
His Game Programming Gems chapters and GameDev articles, etc., like "Common C++ Performance Mistakes in Games".
You can get most of it free with source code on his site: www tantalon com
The key points with vectors:
Use ".reserve()" when you know how many exact or maximum elements you need.
No performance hit for growing an array when there isn't.
Note also at least with a Windows OS and it's paging mechanism that physical RAM pages are not actually until they touched. So you can ".reserve()" a bit more then you need without issue.
Use "resize()" vrs "clear()" to reset element count to zero. "clear()" will cause the vector allocation to free (and thus need to be re-allocated again) where "resize()" doesn't.
For CPUs where it matters (read all modern day PC CPUs) make things cache aligned when possible.
If you can (allocations are not to too large, etc.) use align 16 containers.
Then use a custom STL Allocator that provides align 16 blocks. Easier then you think, use Pete's source code and read the articles.
Also a good on the subject is "Data-Oriented Design (Or Why You Might Be Shooting Yourself in The Foot With OOP)" by
Noel Llopis, et al.
Hi all,
I'm trying to use folly for one of my projects. When I include <folly/dynamic.h>
in my source code, it gave me errors as following:
In file included from /usr/local/include/folly/dynamic.h:522:
In file included from /usr/local/include/folly/dynamic-inl.h:25:
In file included from /usr/local/include/folly/Format.h:36:
In file included from /usr/local/include/folly/String.h:33:
/usr/local/include/folly/ScopeGuard.h:25:10: fatal error: 'folly/detail/UncaughtExceptionCounter.h' file not found
And also I wonder what would be the best way to include folly
without having to specify absolute path to double-conversion
in my Makefile.
Thank you very much!
when I trying fbthrift I found this
"
/home/lee/usr/include/folly/String.h:33:28: fatal error: folly/Demangle.h: No such file or directory #include "folly/Demangle.h"
"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.