Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building under ubuntu 12.04. #4

Closed
billyevans opened this issue May 29, 2013 · 4 comments
Closed

Building under ubuntu 12.04. #4

billyevans opened this issue May 29, 2013 · 4 comments
Assignees

Comments

@billyevans
Copy link

Hi. Thank you for your tool. That's pretty cool.
Your last commit kills speed and building under ubuntu 12.04.

I have tested your previous version and it compressed my 3.3 GB file in 2.6 sec.
But last has 16.35 sec and that time worse than time of pure lz4 library.
And now it doesn't eat 600-800% of cpu just only 150%.

I made a little patch for building under precise. But I am not sure it's nice.
gcc 4.6 doesn't have support for std::launch::deferred.

diff --git a/src/lz4mt.cpp b/src/lz4mt.cpp
index 49c1775..a5a19f4 100644
--- a/src/lz4mt.cpp
+++ b/src/lz4mt.cpp
@@ -8,6 +8,13 @@
 #include "lz4mt_xxh32.h"
 #include "lz4mt_mempool.h"

+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#if (GCC_VERSION == 406)
+#define LAUNCH_SINGLE_THREAD (std::launch::sync)
+#else
+#define LAUNCH_SINGLE_THREAD (std::launch::deferred)
+#endif

 namespace {

@@ -339,7 +346,7 @@ lz4mtCompress(Lz4MtContext* ctx, const Lz4MtStreamDescriptor* sd)
        const bool singleThread      = 0 != (ctx->mode & LZ4MT_MODE_SEQUENTIAL);
        const auto nConcurrency      = std::thread::hardware_concurrency();
        const auto nPool             = singleThread ? 1 : nConcurrency + 1;
-       const auto launch            = singleThread ? std::launch::deferred : std::launch::async;
+       const auto launch            = singleThread ? LAUNCH_SINGLE_THREAD : std::launch::async;

        Lz4Mt::MemPool srcBufferPool(nBlockMaximumSize, nPool);
        Lz4Mt::MemPool dstBufferPool(nBlockMaximumSize, nPool);
@@ -535,7 +542,7 @@ lz4mtDecompress(Lz4MtContext* ctx, Lz4MtStreamDescriptor* sd)
                const bool singleThread      = 0 != (ctx->mode & LZ4MT_MODE_SEQUENTIAL);
                const auto nConcurrency      = std::thread::hardware_concurrency();
                const auto nPool             = singleThread ? 1 : nConcurrency + 1;
-               const auto launch            = singleThread ? std::launch::deferred : std::launch::async;
+               const auto launch            = singleThread ? LAUNCH_SINGLE_THREAD : std::launch::async;

                Lz4Mt::MemPool srcBufferPool(nBlockMaximumSize, nPool);
                Lz4Mt::MemPool dstBufferPool(nBlockMaximumSize, nPool);
@ghost ghost assigned t-mat May 29, 2013
@t-mat
Copy link
Owner

t-mat commented May 29, 2013

Thanks for the report and patch.
I forgot about gcc 4.6 completely 😨

The patch looks good. I'll add #ifdef __GNUC__ for MSVC++ and merge it after some testing.

t-mat added a commit that referenced this issue May 29, 2013
 - Add compatibility layer for older gcc (4.6 or older).
 - Add pseudo std::deffred.
 - Add fallback method for std::hardware_concurrency().
@t-mat
Copy link
Owner

t-mat commented May 29, 2013

I've investigated, and I realised there are two problems.

  • As Alexey mentioned, there is no std::launch::deferred.
  • Also std::thread::hardware_concurrency() always returns 0.

Commit 6863cb0 for issue/4 branch will fix these problems.

Please try it.

@billyevans
Copy link
Author

Thank you.
Everything work fine. And it works faster! 1.75782sec. And doesn't eat a lot of memory while decompressing.

My little advice for you: add flags -Wall -W -Werror -Weffc++ -Wextra in Makefile. It can be usefull.

This one -Weffc++ is a little annoying, but sometimes it can help with uninitialized fields.

t-mat added a commit that referenced this issue May 30, 2013
@t-mat
Copy link
Owner

t-mat commented May 30, 2013

Thanks for testing and advice !
I'll check your compile flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants