Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-20 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes. tberghammer marked 4 inline comments as done. Closed by commit rL250820: Add a new task pool class to LLDB (authored by tberghammer). Changed prior to commit: http://reviews.llvm.org/D13727?vs=37566&id=37865#toc Reposito

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-19 Thread Greg Clayton via lldb-commits
clayborg added a comment. Yes, lets get this in an iterate on it afterwards! http://reviews.llvm.org/D13727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-19 Thread Todd Fiala via lldb-commits
tfiala added a comment. That seems totally reasonable. We're fine with "this isn't an issue until it's proven to be an issue." (And I like stressing the concurrency - we initially found a number of issues when the concurrent test runner came online in the first place). http://reviews.llvm.or

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-19 Thread Pavel Labath via lldb-commits
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. I think this can go in now. Currently, the paralelization happens on compile unit level, and the test programs generally only have one compile unit. Since the threads are created on an as-need

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-19 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. I thought a bit about the points raised by Todd and in general I am happy with overloading the system during testing with a very high number of tests as it will most likely help us to detect race conditions and based on my testing (on a 40 core Linux machine) it isn

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Zachary Turner via lldb-commits
zturner added a comment. Sorry, should have mentioned that the lgtm is contingent on Todd's concerns. I like the idea of having a setting in LLDB that controls the maximum number of threads to use for parallel work. We should probably set this at a very h igh level in dotest so that all insta

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Zachary Turner via lldb-commits
zturner accepted this revision. zturner added a comment. Your example makes sense. So go ahead and delete the std async implementation for now. As Tamas said, its very easy to put in, so a better thing to do perhaps is once there's something doing actual parallel work, just test it in a real

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Todd Fiala via lldb-commits
tfiala added a comment. I'm in agreement with Pavel's assessment on this. Regarding the tests, I had brought that up with Greg earlier. We can handle that in a few different ways: - We do nothing, and perhaps some collections of tests run slower if they are all pounding on their thread pools

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Pavel Labath via lldb-commits
labath added a comment. In http://reviews.llvm.org/D13727#268747, @tberghammer wrote: > Based on Pavel's example and some additional experimenting we done I am not > sure if std::async will give us any benefit even on Windows as it don't limit > the number of threads to the number of cores (bec

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. Based on Pavel's example and some additional experimenting we done I am not sure if std::async will give us any benefit even on Windows as it don't limit the number of threads to the number of cores (because it can't do if it want to implement the standard). I have

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 37566. tberghammer added a comment. Create optional std::async based implementation http://reviews.llvm.org/D13727 Files: include/lldb/Utility/TaskPool.h source/Utility/CMakeLists.txt source/Utility/TaskPool.cpp unittests/Utility/CMakeLists.txt

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-16 Thread Pavel Labath via lldb-commits
labath added a comment. Zachary, I don't think using std::async is a good idea because it provides a very different threading model than the one we want here. Let me demonstrate that with an example: #include #include #include #include #include using namespace std; u

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg added a comment. Stopping the threads is fine as it seems to be desired from most others. http://reviews.llvm.org/D13727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. In http://reviews.llvm.org/D13727#268233, @zturner wrote: > In http://reviews.llvm.org/D13727#268086, @clayborg wrote: > > > > Yes. But an implementation of std::async is either going to use a global > > > thread pool or it's not. If it does there's no problem, and

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Zachary Turner via lldb-commits
zturner added a comment. In http://reviews.llvm.org/D13727#268086, @clayborg wrote: > > Yes. But an implementation of std::async is either going to use a global > > thread pool or it's not. If it does there's no problem, and if it doesn't, > > it's going to create one thread for each call, an

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Todd Fiala via lldb-commits
tfiala added a comment. In http://reviews.llvm.org/D13727#268096, @clayborg wrote: > In http://reviews.llvm.org/D13727#268091, @tberghammer wrote: > > > I agree that parking the threads in the kernel should be very cheap (I am > > not sure about Windows) but on high end multi core machines havin

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Joe Ranieri via lldb-commits
This may or may not be relevant, but the stack size for std::thread on OS X is a fixed size of 512KB (DEFAULT_STACK_SIZE in pthread.c). There's no way to specify a stack size with std::thread and no per-process override like I think you can do with rlimit on Linux. It's an issue I ran into when imp

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. I agree that parking the threads in the kernel should be very cheap (I am not sure about Windows) but on high end multi core machines having 40+ threads around just to wait for work is a bit strange for me too and it definitely makes debugging of LLDB more difficult

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg added a comment. In http://reviews.llvm.org/D13727#268091, @tberghammer wrote: > I agree that parking the threads in the kernel should be very cheap (I am not > sure about Windows) but on high end multi core machines having 40+ threads > around just to wait for work is a bit strange fo

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg added a comment. In http://reviews.llvm.org/D13727#268084, @tberghammer wrote: > Addressing comments from the discussion with destroying the treads not in use > while keeping a global thread pool with at most hardware_concurrency threads. We should perf test this, but I would be OK wi

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 37498. tberghammer added a comment. Addressing comments from the discussion with destroying the treads not in use while keeping a global thread pool with at most hardware_concurrency threads. IMO this update also simplifies the implementation of the Thre

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg added a comment. > Yes. But an implementation of std::async is either going to use a global > thread pool or it's not. If it does there's no problem, and if it doesn't, > it's going to create one thread for each call, and when the work in that > thread is done, the thread will exit.

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Zachary Turner via lldb-commits
zturner added a comment. In http://reviews.llvm.org/D13727#268066, @clayborg wrote: > In http://reviews.llvm.org/D13727#268053, @zturner wrote: > > > The main thought I had was just that it would make the code simpler and > > delegate more of the synchronization stuff to the library. But if we

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg added a comment. In http://reviews.llvm.org/D13727#268053, @zturner wrote: > The main thought I had was just that it would make the code simpler and > delegate more of the synchronization stuff to the library. But if we don't > get any of that benefit then I guess there's no point in

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Todd Fiala via lldb-commits
tfiala added a subscriber: tfiala. tfiala added a comment. In http://reviews.llvm.org/D13727#268053, @zturner wrote: > The main thought I had was just that it would make the code simpler and > delegate more of the synchronization stuff to the library. But if we don't > get any of that benefit

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Greg Clayton via lldb-commits
clayborg accepted this revision. clayborg added a comment. Very nice! I look forward to seeing this patch and the associated DWARF patches make it in! http://reviews.llvm.org/D13727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://l

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Zachary Turner via lldb-commits
zturner added a comment. The main thought I had was just that it would make the code simpler and delegate more of the synchronization stuff to the library. But if we don't get any of that benefit then I guess there's no point in doing that. That said, I really dont' want to see 48 threads runn

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. Zach: I thought about your idea and I think it won't make the code any simpler because your suggestion would only implement the functionality what is currently implemented by TaskPool and TaskPoolImpl what is using only a single condition variable and a single queue

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-15 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 37492. tberghammer marked 7 inline comments as done. tberghammer added a comment. - Address review comments - Add some more documentation - Add some unit tests http://reviews.llvm.org/D13727 Files: include/lldb/Utility/TaskPool.h source/Utility/CMak

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Zachary Turner via lldb-commits
zturner added a comment. Well, it's not just an optimization. Threading code is hard to reason about, and the more complicated an implementation the more likely it is to have race conditions or other problems. So any opportunity to reduce the amount of manual thread management is a win in tha

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Greg Clayton via lldb-commits
clayborg added a comment. Zach: If these are implementation details, lets get this in first and then worry about optimizations later. http://reviews.llvm.org/D13727 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Zachary Turner via lldb-commits
zturner added a comment. The only real suggestion / question I have is a design one. By using this implementation we can't take advantage of the system thread pool. That was the point of using std async in the first place, but we found that it doesn't always limit the number of threads. Maybe

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Zachary Turner via lldb-commits
zturner added a comment. I thought about this some more and I'm fine with going with a single implementation and not using std async. It would be nice to take advantage of any deep optimizations std::async provides over a hand-rolled solution, but at the same time there's a cost to adding comp

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Greg Clayton via lldb-commits
clayborg added a comment. Any std::async adoption will need to be able to deliver tasks as they complete via "TaskRunner::WaitForNextCompletedTask()". We had a previous example where 1000 items could be pushed onto a std::vector of tasks and then the code was doing: for (i=0; ihttp://reviews

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Greg Clayton via lldb-commits
clayborg requested changes to this revision. clayborg added a comment. I agree with labath's comments and see if we can move TaskPoolImpl into the .cpp file. Comment at: include/lldb/Utility/TaskPool.h:39-66 @@ +38,30 @@ + +class TaskPoolImpl +{ +public: +Ta

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Zachary Turner via lldb-commits
zturner added a comment. Ok, it seems reasonable to just use std::async on platforms that this is ok on, and not use it on platforms which it's not ok on. I think it should be enabled on Windows, but I'll leave it up to you to decide whether it's a whitelist or a blacklist. http://reviews.ll

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment. We can change this class to use std::async on Windows and an std::thread based implementation on Linux with the same interface (other OS-es should be decided) but I would prefer to use just 1 logic as it is easier to maintain. Limiting the number of threads with add

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Zachary Turner via lldb-commits
zturner added a comment. Can this be done in such a way that everything boils down to a single call to std::async on platforms that support thread limiting? Alternatively, why not just put a semaphore inside of the lambda that you run with std::async to limit the number of threads? This seems

Re: [Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Pavel Labath via lldb-commits
labath requested changes to this revision. labath added a comment. This revision now requires changes to proceed. Although it may not seem from the number of my comments, I actually quite like this implementation. However, I think more work needs to be done to make this future-proof. - we defin

[Lldb-commits] [PATCH] D13727: Add task pool to LLDB

2015-10-14 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision. tberghammer added reviewers: labath, clayborg, vharron, zturner. tberghammer added a subscriber: lldb-commits. Herald added a subscriber: iancottrell. Add a new task pool class to LLDB to make it easy to execute tasks in parallel Basic design goals: * Have a ver