Mir

Merge lp://qastaging/~albaguirre/mir/recycle-compositor-threads into lp://qastaging/mir

Proposed by Alberto Aguirre
Status: Rejected
Rejected by: Alberto Aguirre
Proposed branch: lp://qastaging/~albaguirre/mir/recycle-compositor-threads
Merge into: lp://qastaging/mir
Diff against target: 1605 lines (+996/-137)
16 files modified
include/test/mir_test/signal.h (+1/-0)
include/test/mir_test_doubles/mock_compositor_loop.h (+44/-0)
include/test/mir_test_doubles/mock_compositor_thread.h (+66/-0)
src/server/compositor/CMakeLists.txt (+2/-0)
src/server/compositor/compositor_thread.cpp (+141/-0)
src/server/compositor/compositor_thread.h (+89/-0)
src/server/compositor/compositor_thread_factory.cpp (+32/-0)
src/server/compositor/compositor_thread_factory.h (+44/-0)
src/server/compositor/default_configuration.cpp (+2/-0)
src/server/compositor/multi_threaded_compositor.cpp (+47/-32)
src/server/compositor/multi_threaded_compositor.h (+10/-8)
tests/integration-tests/test_surface_stack_with_compositor.cpp (+11/-0)
tests/mir_test/signal.cpp (+6/-0)
tests/unit-tests/compositor/CMakeLists.txt (+1/-0)
tests/unit-tests/compositor/test_compositor_thread.cpp (+256/-0)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+244/-97)
To merge this branch: bzr merge lp://qastaging/~albaguirre/mir/recycle-compositor-threads
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Needs Information
Daniel van Vugt Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+232791@code.qastaging.launchpad.net

Commit message

Recycle compositor threads whenever possible (LP: #1362841)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Sounds like a good-old thread pool pattern [1]. Does it therefore have to be compositor specific? That would seem to limit code reuse.

[1] http://en.wikipedia.org/wiki/Thread_pool_pattern

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, so two questions right now:

(1) Does the thread pool really need to be compositor-specific? That does limit code reuse.

(2) Given this is a workaround for one specific chipset, isn't "1605 lines (+996/-137)" an overkill? Seems rather large given it's a workaround for just one specific chip. Such workarounds you would hope are temporary, and so should be small so that they might be eliminated in future.

The size of the hammer seems disproportionate to the nail :)

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

If it's feasible I would too like to reduce the changes in the Compositor class. Based on Daniel's ThreadPool observation an alternative idea is:

class ThreadPool
{
// When the shared_ptr is released the thread will be marked as available for reuse
// The 'id' is used to enable reusing threads if the ThreadPool implementation supports it.
virtual std::shared_ptr<std::thread> run(void const* id, std::function<void()> const& functor) = 0;
virtual void clear_unused_threads() = 0;
};

// And either dependency on abstract ThreadPool:
MultiThreadedCompositor(...std::shared_ptr<ThreadPool> const& tp...);
// or it might as well use an object variable (abstract class not necessary) for now if this doesn't hinder testing (probably not a problem for testing since we are currently using threads directly internally anyway):
class MultiThreadedCompositor { ReusableThreadPool thread_pool; };

So MultiThreadedCompositor stays as it is more or less, and reverting to the previous behavior is easy: either revert the thread pool changes in MTC, or use a simple thread pool implementation that doesn't reuse threads.

"Needs discussion"

review: Needs Information
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> OK, so two questions right now:
>
> (1) Does the thread pool really need to be compositor-specific? That does
> limit code reuse.
>
> (2) Given this is a workaround for one specific chipset, isn't "1605 lines
> (+996/-137)" an overkill? Seems rather large given it's a workaround for just
> one specific chip. Such workarounds you would hope are temporary, and so
> should be small so that they might be eliminated in future.
>
> The size of the hammer seems disproportionate to the nail :)

1) No it doesn't need to be. I'll make it generic.

2) I don't think so, since a bulk of the MP is adding tests (which we should never see as overkill).

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> If it's feasible I would too like to reduce the changes in the Compositor
> class. Based on Daniel's ThreadPool observation an alternative idea is:
>
> class ThreadPool
> {
> // When the shared_ptr is released the thread will be marked as available for
> reuse
> // The 'id' is used to enable reusing threads if the ThreadPool implementation
> supports it.
> virtual std::shared_ptr<std::thread> run(void const* id, std::function<void()>
> const& functor) = 0;
> virtual void clear_unused_threads() = 0;
> };
>
> // And either dependency on abstract ThreadPool:
> MultiThreadedCompositor(...std::shared_ptr<ThreadPool> const& tp...);
> // or it might as well use an object variable (abstract class not necessary)
> for now if this doesn't hinder testing (probably not a problem for testing
> since we are currently using threads directly internally anyway):
> class MultiThreadedCompositor { ReusableThreadPool thread_pool; };
>
> So MultiThreadedCompositor stays as it is more or less, and reverting to the
> previous behavior is easy: either revert the thread pool changes in MTC, or
> use a simple thread pool implementation that doesn't reuse threads.
>
> "Needs discussion"

Ok, I'll rework.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Just being careful what we wish for...

If you do rework it and find the result is more complex/larger than this branch then maybe we should keep this one. A non-generalised solution like this one is easier to remove later if a driver fix or simpler workaround materializes.

Unmerged revisions

1879. By Alberto Aguirre

cleanup tests

1878. By Alberto Aguirre

merge lp:mir/devel

1877. By Alberto Aguirre

Recycle compositor threads whenever possible

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches