Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-3046

Stout's UUID re-seeds a new random generator during each call to UUID::random.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.24.2, 0.25.0
    • Component/s: stout
    • Labels:
    • Target Version/s:
    • Story Points:
      3

      Description

      Per Stephan Erb and Kevin Sweeney's observations on MESOS-2940, stout's UUID abstraction is re-seeding the random generator during each call to UUID::random(), which is really expensive.

      This is confirmed in the perf graph from MESOS-2940.

      1. tl.cpp
        0.4 kB
        Klaus Ma

        Activity

        Hide
        nekto0n Nikita Vetoshkin added a comment -

        Out of curiosity took a look at this one.
        In MESOS-2940 it was suggested to put generator in thread_local like this

        diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
        index e8ebe0b..b0facb2 100644
        --- a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
        +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
        @@ -28,7 +28,7 @@ struct UUID : boost::uuids::uuid
         public:
           static UUID random()
           {
        -    return UUID(boost::uuids::random_generator()());
        +    return UUID(random_generator());
           }
         
           static UUID fromBytes(const std::string& s)
        @@ -62,6 +62,7 @@ public:
         private:
           explicit UUID(const boost::uuids::uuid& uuid)
             : boost::uuids::uuid(uuid) {}
        +  static thread_local boost::uuids::random_generator random_generator;
         };
         
         #endif // __STOUT_UUID_HPP__
        

        fails with GCC 5.1.1 on Fedora x64:

        ./.libs/libmesos.so: error: undefined reference to 'TLS init function for UUID::random_generator'
        ./.libs/libmesos.so: error: undefined reference to 'UUID::random_generator'
        

        However, putting static in function does work

        --- a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
        +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
        @@ -28,7 +28,8 @@ struct UUID : boost::uuids::uuid
         public:
           static UUID random()
           {
        -    return UUID(boost::uuids::random_generator()());
        +    static thread_local boost::uuids::random_generator random_generator;
        +    return UUID(random_generator());
           }
         
           static UUID fromBytes(const std::string& s)
        
        

        But I wonder whether it contradicts with "no static objects with non-trivial constructors" policy, because lifetime of this object is event more sophisticated that ordinary static with per thread list of destructors to call upon thread exit and so on.

        Show
        nekto0n Nikita Vetoshkin added a comment - Out of curiosity took a look at this one. In MESOS-2940 it was suggested to put generator in thread_local like this diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp index e8ebe0b..b0facb2 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp @@ -28,7 +28,7 @@ struct UUID : boost::uuids::uuid public: static UUID random() { - return UUID(boost::uuids::random_generator()()); + return UUID(random_generator()); } static UUID fromBytes(const std::string& s) @@ -62,6 +62,7 @@ public: private: explicit UUID(const boost::uuids::uuid& uuid) : boost::uuids::uuid(uuid) {} + static thread_local boost::uuids::random_generator random_generator; }; #endif // __STOUT_UUID_HPP__ fails with GCC 5.1.1 on Fedora x64: ./.libs/libmesos.so: error: undefined reference to 'TLS init function for UUID::random_generator' ./.libs/libmesos.so: error: undefined reference to 'UUID::random_generator' However, putting static in function does work --- a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp @@ -28,7 +28,8 @@ struct UUID : boost::uuids::uuid public: static UUID random() { - return UUID(boost::uuids::random_generator()()); + static thread_local boost::uuids::random_generator random_generator; + return UUID(random_generator()); } static UUID fromBytes(const std::string& s) But I wonder whether it contradicts with "no static objects with non-trivial constructors" policy, because lifetime of this object is event more sophisticated that ordinary static with per thread list of destructors to call upon thread exit and so on.
        Hide
        klaus1982 Klaus Ma added a comment -

        I'd suggest to use static var in random() as Nikita Vetoshkin proposed, because
        1. The static member still need to be constructed in a CPP file in gcc 4.8.4 (ubuntu 14.04); refer to the attachment for the example
        2. According to the description in cppreference, the static did not affect its thread storage duration

        5) The thread_local keyword is only allowed for objects declared at namespace scope, objects declared at block scope, and static data members. It indicates that the object has thread storage duration. It can be combined with static or extern to specify internal or external linkage (except for static data members which always have external linkage), respectively, but that additional static doesn't affect the storage duration.

        Show
        klaus1982 Klaus Ma added a comment - I'd suggest to use static var in random() as Nikita Vetoshkin proposed, because 1. The static member still need to be constructed in a CPP file in gcc 4.8.4 (ubuntu 14.04); refer to the attachment for the example 2. According to the description in cppreference , the static did not affect its thread storage duration 5) The thread_local keyword is only allowed for objects declared at namespace scope, objects declared at block scope, and static data members. It indicates that the object has thread storage duration. It can be combined with static or extern to specify internal or external linkage (except for static data members which always have external linkage), respectively, but that additional static doesn't affect the storage duration.
        Hide
        klaus1982 Klaus Ma added a comment -

        Please refer to the attachment for the example that build failed in Ubuntu 14.04 (GCC 4.8.4) without initialization of static member.

        Show
        klaus1982 Klaus Ma added a comment - Please refer to the attachment for the example that build failed in Ubuntu 14.04 (GCC 4.8.4) without initialization of static member.
        Hide
        klaus1982 Klaus Ma added a comment -

        A patch was updated at https://reviews.apache.org/r/38102/; Benjamin Mahler, would you help to review?

        Show
        klaus1982 Klaus Ma added a comment - A patch was updated at https://reviews.apache.org/r/38102/ ; Benjamin Mahler , would you help to review?
        Hide
        klaus1982 Klaus Ma added a comment -

        Benjamin Mahler, would you help to review the patch? maybe we can release it in 0.25.0.

        Show
        klaus1982 Klaus Ma added a comment - Benjamin Mahler , would you help to review the patch? maybe we can release it in 0.25.0.
        Hide
        bmahler Benjamin Mahler added a comment -

        Thanks Nikita Vetoshkin and Klaus Ma, sorry for the delay.

        commit d5d44d1230e9a459a4e32cf3d24f3b4819f27f13
        Author: Klaus Ma <klaus@cguru.net>
        Date:   Thu Sep 17 20:43:27 2015 -0700
        
            Fixed a performance issue in UUID generation.
        
            Stout's UUID abstraction is re-seeding the random generator
            during each call to UUID::random(), which is really expensive.
        
            Review: https://reviews.apache.org/r/38102
        
        Show
        bmahler Benjamin Mahler added a comment - Thanks Nikita Vetoshkin and Klaus Ma , sorry for the delay. commit d5d44d1230e9a459a4e32cf3d24f3b4819f27f13 Author: Klaus Ma <klaus@cguru.net> Date: Thu Sep 17 20:43:27 2015 -0700 Fixed a performance issue in UUID generation. Stout's UUID abstraction is re-seeding the random generator during each call to UUID::random(), which is really expensive. Review: https://reviews.apache.org/r/38102
        Hide
        arojas Alexander Rojas added a comment -

        The submitted patch breaks the build on OSX with the following error message:

        g++ -DPACKAGE_NAME=\"libprocess\" -DPACKAGE_TARNAME=\"libprocess\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"libprocess\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libprocess\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_APR_POOLS_H=1 -DHAVE_LIBAPR_1=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_LIBCURL=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_LIBZ=1 -DHAVE_LIBDL=1 -I. -I../../../../3rdparty/libprocess/3rdparty  -I../../../../3rdparty/libprocess/3rdparty/stout/include -Iprotobuf-2.5.0/src  -Igmock-1.7.0/gtest/include -Igmock-1.7.0/include -Iboost-1.53.0 -Ipicojson-4f93734 -Iglog-0.3.3/src -I/usr/local/opt/openssl/include -I/usr/local/opt/libevent/include -I/usr/local/opt/subversion/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/apr-1.0   -g -O0 -Wno-unused-local-typedef -std=c++11 -stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1 -DGTEST_LANG_CXX11 -MT stout_tests-uuid_tests.o -MD -MP -MF .deps/stout_tests-uuid_tests.Tpo -c -o stout_tests-uuid_tests.o `test -f 'stout/tests/uuid_tests.cpp' || echo '../../../../3rdparty/libprocess/3rdparty/'`stout/tests/uuid_tests.cpp
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/uuid_tests.cpp:21:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression
              new boost::uuids::random_generator();
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this
            static __thread boost::uuids::random_generator* generator =
                                                            ^
        1 error generated.
        make[7]: *** [stout_tests-uuid_tests.o] Error 1
        make[7]: *** Waiting for unfinished jobs....
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp:43:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression
              new boost::uuids::random_generator();
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this
            static __thread boost::uuids::random_generator* generator =
                                                            ^
        1 error generated.
        make[7]: *** [stout_tests-os_tests.o] Error 1
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp:27:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression
              new boost::uuids::random_generator();
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this
            static __thread boost::uuids::random_generator* generator =
                                                            ^
        1 error generated.
        make[7]: *** [stout_tests-protobuf_tests.o] Error 1
        make[6]: *** [check-am] Error 2
        make[5]: *** [check-recursive] Error 1
        make[4]: *** [check] Error 2
        make[3]: *** [check-recursive] Error 1
        make[2]: *** [check-recursive] Error 1
        make[1]: *** [check] Error 2
        make: *** [check-recursive] Error 1
        

        Switching to thread_local doesn't help:

        g++ -DPACKAGE_NAME=\"libprocess\" -DPACKAGE_TARNAME=\"libprocess\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"libprocess\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libprocess\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_APR_POOLS_H=1 -DHAVE_LIBAPR_1=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_LIBCURL=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_LIBZ=1 -DHAVE_LIBDL=1 -I. -I../../../../3rdparty/libprocess/3rdparty  -I../../../../3rdparty/libprocess/3rdparty/stout/include -Iprotobuf-2.5.0/src  -Igmock-1.7.0/gtest/include -Igmock-1.7.0/include -Iboost-1.53.0 -Ipicojson-4f93734 -Iglog-0.3.3/src -I/usr/local/opt/openssl/include -I/usr/local/opt/libevent/include -I/usr/local/opt/subversion/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/apr-1.0   -g -O0 -Wno-unused-local-typedef -std=c++11 -stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1 -DGTEST_LANG_CXX11 -MT stout_tests-uuid_tests.o -MD -MP -MF .deps/stout_tests-uuid_tests.Tpo -c -o stout_tests-uuid_tests.o `test -f 'stout/tests/uuid_tests.cpp' || echo '../../../../3rdparty/libprocess/3rdparty/'`stout/tests/uuid_tests.cpp
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/uuid_tests.cpp:21:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target
            static thread_local boost::uuids::random_generator* generator =
                   ^
        1 error generated.
        make[7]: *** [stout_tests-uuid_tests.o] Error 1
        make[7]: *** Waiting for unfinished jobs....
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp:43:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target
            static thread_local boost::uuids::random_generator* generator =
                   ^
        1 error generated.
        make[7]: *** [stout_tests-os_tests.o] Error 1
        In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp:27:
        ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target
            static thread_local boost::uuids::random_generator* generator =
                   ^
        1 error generated.
        make[7]: *** [stout_tests-protobuf_tests.o] Error 1
        make[6]: *** [check-am] Error 2
        make[5]: *** [check-recursive] Error 1
        make[4]: *** [check] Error 2
        make[3]: *** [check-recursive] Error 1
        make[2]: *** [check-recursive] Error 1
        make[1]: *** [check] Error 2
        make: *** [check-recursive] Error 1
        
        Show
        arojas Alexander Rojas added a comment - The submitted patch breaks the build on OSX with the following error message: g++ -DPACKAGE_NAME=\"libprocess\" -DPACKAGE_TARNAME=\"libprocess\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"libprocess\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libprocess\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_APR_POOLS_H=1 -DHAVE_LIBAPR_1=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_LIBCURL=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_LIBZ=1 -DHAVE_LIBDL=1 -I. -I../../../../3rdparty/libprocess/3rdparty -I../../../../3rdparty/libprocess/3rdparty/stout/include -Iprotobuf-2.5.0/src -Igmock-1.7.0/gtest/include -Igmock-1.7.0/include -Iboost-1.53.0 -Ipicojson-4f93734 -Iglog-0.3.3/src -I/usr/local/opt/openssl/include -I/usr/local/opt/libevent/include -I/usr/local/opt/subversion/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/apr-1.0 -g -O0 -Wno-unused-local-typedef -std=c++11 -stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1 -DGTEST_LANG_CXX11 -MT stout_tests-uuid_tests.o -MD -MP -MF .deps/stout_tests-uuid_tests.Tpo -c -o stout_tests-uuid_tests.o `test -f 'stout/tests/uuid_tests.cpp' || echo '../../../../3rdparty/libprocess/3rdparty/'`stout/tests/uuid_tests.cpp In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/uuid_tests.cpp:21: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression new boost::uuids::random_generator(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this static __thread boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-uuid_tests.o] Error 1 make[7]: *** Waiting for unfinished jobs.... In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp:43: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression new boost::uuids::random_generator(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this static __thread boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-os_tests.o] Error 1 In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp:27: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:34:7: error: initializer for thread-local variable must be a constant expression new boost::uuids::random_generator(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:53: note: use 'thread_local' to allow this static __thread boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-protobuf_tests.o] Error 1 make[6]: *** [check-am] Error 2 make[5]: *** [check-recursive] Error 1 make[4]: *** [check] Error 2 make[3]: *** [check-recursive] Error 1 make[2]: *** [check-recursive] Error 1 make[1]: *** [check] Error 2 make: *** [check-recursive] Error 1 Switching to thread_local doesn't help: g++ -DPACKAGE_NAME=\"libprocess\" -DPACKAGE_TARNAME=\"libprocess\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"libprocess\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libprocess\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_APR_POOLS_H=1 -DHAVE_LIBAPR_1=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_LIBCURL=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_LIBZ=1 -DHAVE_LIBDL=1 -I. -I../../../../3rdparty/libprocess/3rdparty -I../../../../3rdparty/libprocess/3rdparty/stout/include -Iprotobuf-2.5.0/src -Igmock-1.7.0/gtest/include -Igmock-1.7.0/include -Iboost-1.53.0 -Ipicojson-4f93734 -Iglog-0.3.3/src -I/usr/local/opt/openssl/include -I/usr/local/opt/libevent/include -I/usr/local/opt/subversion/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/apr-1.0 -g -O0 -Wno-unused-local-typedef -std=c++11 -stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1 -DGTEST_LANG_CXX11 -MT stout_tests-uuid_tests.o -MD -MP -MF .deps/stout_tests-uuid_tests.Tpo -c -o stout_tests-uuid_tests.o `test -f 'stout/tests/uuid_tests.cpp' || echo '../../../../3rdparty/libprocess/3rdparty/'`stout/tests/uuid_tests.cpp In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/uuid_tests.cpp:21: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target static thread_local boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-uuid_tests.o] Error 1 make[7]: *** Waiting for unfinished jobs.... In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp:43: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target static thread_local boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-os_tests.o] Error 1 In file included from ../../../../3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp:27: ../../../../3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp:33:12: error: thread-local storage is not supported for the current target static thread_local boost::uuids::random_generator* generator = ^ 1 error generated. make[7]: *** [stout_tests-protobuf_tests.o] Error 1 make[6]: *** [check-am] Error 2 make[5]: *** [check-recursive] Error 1 make[4]: *** [check] Error 2 make[3]: *** [check-recursive] Error 1 make[2]: *** [check-recursive] Error 1 make[1]: *** [check] Error 2 make: *** [check-recursive] Error 1
        Hide
        nekto0n Nikita Vetoshkin added a comment -

        Seems like clang + libstdc++ issue

        thread_local support currently requires the C++ runtime library from g++-4.8 or later.

        from http://clang.llvm.org/cxx_status.html.

        Seems like a frequent issue, there is a corresponding fix for TextMate.

        Show
        nekto0n Nikita Vetoshkin added a comment - Seems like clang + libstdc++ issue thread_local support currently requires the C++ runtime library from g++-4.8 or later. from http://clang.llvm.org/cxx_status.html . Seems like a frequent issue, there is a corresponding fix for TextMate.
        Hide
        haosdent@gmail.com haosdent added a comment -

        what's your clang version? Seems work for me.

        My clang version

        Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
        Target: x86_64-apple-darwin14.4.0
        Thread model: posix
        

        Could your compiler pass this code snippet directly.

        #include <iostream>
        #include <string>
        
        #include <boost/uuid/uuid.hpp>
        #include <boost/uuid/uuid_generators.hpp>
        #include <boost/uuid/uuid_io.hpp>
        
        #ifdef __APPLE__
        #define THREAD_LOCAL __thread
        #else
        #define THREAD_LOCAL thread_local
        #endif
        
        struct UUID : boost::uuids::uuid
        {
        public:
          static UUID random()
          {
            typedef boost::uuids::random_generator generator;
            static THREAD_LOCAL generator* uuid_generator = new generator();
            return UUID((*uuid_generator)());
          }
        
        private:
          explicit UUID(const boost::uuids::uuid& uuid)
            : boost::uuids::uuid(uuid) {}
        };
        
        int main() {
          std::cout << UUID::random() << std::endl;
        }
        
        Show
        haosdent@gmail.com haosdent added a comment - what's your clang version? Seems work for me. My clang version Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix Could your compiler pass this code snippet directly. #include <iostream> #include <string> #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_io.hpp> #ifdef __APPLE__ #define THREAD_LOCAL __thread # else #define THREAD_LOCAL thread_local #endif struct UUID : boost::uuids::uuid { public : static UUID random() { typedef boost::uuids::random_generator generator; static THREAD_LOCAL generator* uuid_generator = new generator(); return UUID((*uuid_generator)()); } private : explicit UUID( const boost::uuids::uuid& uuid) : boost::uuids::uuid(uuid) {} }; int main() { std::cout << UUID::random() << std::endl; }
        Hide
        arojas Alexander Rojas added a comment -

        My clang version is:

        Apple LLVM version 7.0.0 (clang-700.0.72)
        Target: x86_64-apple-darwin14.5.0
        Thread model: posix
        

        It just updated this morning.

        Show
        arojas Alexander Rojas added a comment - My clang version is: Apple LLVM version 7.0.0 (clang-700.0.72) Target: x86_64-apple-darwin14.5.0 Thread model: posix It just updated this morning.
        Hide
        arojas Alexander Rojas added a comment -

        Nikita Vetoshkin The fix requires using the boost thread binary library, which is a no-no for Mesos.

        Show
        arojas Alexander Rojas added a comment - Nikita Vetoshkin The fix requires using the boost thread binary library, which is a no-no for Mesos.
        Hide
        haosdent@gmail.com haosdent added a comment -

        Oh, I use /usr/local/opt/llvm/bin/clang++ (install through brew)

        clang version 3.6.2 (tags/RELEASE_362/final)
        Target: x86_64-apple-darwin14.4.0
        Thread model: posix
        

        could not pass

        use default /usr/bin/clang++ could pass.

        Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
        Target: x86_64-apple-darwin14.4.0
        Thread model: posix
        
        Show
        haosdent@gmail.com haosdent added a comment - Oh, I use /usr/local/opt/llvm/bin/clang++ (install through brew) clang version 3.6.2 (tags/RELEASE_362/ final ) Target: x86_64-apple-darwin14.4.0 Thread model: posix could not pass use default /usr/bin/clang++ could pass. Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix
        Hide
        haosdent@gmail.com haosdent added a comment -

        Because we has already add libc++ as compile flag. So I think maybe have some other reason.

        Show
        haosdent@gmail.com haosdent added a comment - Because we has already add libc++ as compile flag. So I think maybe have some other reason.
        Hide
        haosdent@gmail.com haosdent added a comment -

        And this problem should not have relations to boost::uuid. This code snippet also could not pass.

        #include <iostream>
        #include <string>
        
        #ifdef __APPLE__
        #define THREAD_LOCAL __thread
        #else
        #define THREAD_LOCAL thread_local
        #endif
        
        int main() {
          static THREAD_LOCAL std::string* str = new std::string();
        }
        
        Show
        haosdent@gmail.com haosdent added a comment - And this problem should not have relations to boost::uuid. This code snippet also could not pass. #include <iostream> #include <string> #ifdef __APPLE__ #define THREAD_LOCAL __thread # else #define THREAD_LOCAL thread_local #endif int main() { static THREAD_LOCAL std::string* str = new std::string(); }
        Hide
        arojas Alexander Rojas added a comment -

        I think the root reason is mixing the static specifier with THREAD_LOCAL.

        Show
        arojas Alexander Rojas added a comment - I think the root reason is mixing the static specifier with THREAD_LOCAL .
        Hide
        haosdent@gmail.com haosdent added a comment -

        A patch to fix the compile error: https://reviews.apache.org/r/38481/

        Show
        haosdent@gmail.com haosdent added a comment - A patch to fix the compile error: https://reviews.apache.org/r/38481/
        Hide
        klaus1982 Klaus Ma added a comment -

        haosdent/Alexander Rojas, good catch! thanks .

        Show
        klaus1982 Klaus Ma added a comment - haosdent / Alexander Rojas , good catch! thanks .
        Hide
        bmahler Benjamin Mahler added a comment -

        OS X compiler error fix:

        commit 42971bd95bfc2630e52888a0388e0a691ccaef00
        Author: haosdent huang <haosdent@gmail.com>
        Date:   Fri Sep 18 09:22:57 2015 -0700
        
            Fixed a compiler error in UUID on OSX.
        
            Review: https://reviews.apache.org/r/38481
        
        Show
        bmahler Benjamin Mahler added a comment - OS X compiler error fix: commit 42971bd95bfc2630e52888a0388e0a691ccaef00 Author: haosdent huang <haosdent@gmail.com> Date: Fri Sep 18 09:22:57 2015 -0700 Fixed a compiler error in UUID on OSX. Review: https://reviews.apache.org/r/38481

          People

          • Assignee:
            klaus1982 Klaus Ma
            Reporter:
            bmahler Benjamin Mahler
            Shepherd:
            Benjamin Mahler
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development