Mir

Merge lp:~vanvugt/mir/fix-1546933-2 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 3378
Proposed branch: lp:~vanvugt/mir/fix-1546933-2
Merge into: lp:mir
Diff against target: 154 lines (+123/-1)
3 files modified
src/client/mir_connection.cpp (+4/-1)
tests/acceptance-tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/test_client_logging.cpp (+118/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1546933-2
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Chris Halse Rogers Approve
Alan Griffiths Approve
Review via email: mp+287893@code.launchpad.net

Commit message

Fix incomplete client performance report (LP: #1546933)

Although the regression test is more interesting than the fix.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3379
https://mir-jenkins.ubuntu.com/job/mir-ci/478/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/305/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/330
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/322
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/322
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/314/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/314
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/314/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/314
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/314/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/314
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/314/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/314/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/478/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Wouldn't it be easier to call set_logger(fake_shared(string_stream_logger)) and avoid needing StubConnectionConfiguration and the "Awkwardly static" data member?

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

Good observation, but that did not work when I was previously sharing the ClientSurfaces test case. So I had to do it this complicated way (which took an extra afternoon).

Since moving the test to a new source file however, it might now be possible...

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

I'm hoping this bug fix lands in one form or another soon. We've been arguing over test case syntax for a fortnight now, while the trivial fix itself has remained unchanged.

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

Alan:

I have prototyped the set_logger approach but it does not work, for shared process reasons... If you think you can fix it, be my guest:
  https://code.launchpad.net/~mir-team/mir/fix-1546933-3/+merge/288056

The only working solutions at present are this branch and the old one:
  https://code.launchpad.net/~vanvugt/mir/fix-1546933/+merge/286782

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3381
https://mir-jenkins.ubuntu.com/job/mir-ci/489/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/320/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/346
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/338
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/338
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/329/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/329
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/329/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/329
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/329/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/329
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/329/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/329/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/489/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Oh dear. A regression of bug 1540731?

[ FAILED ] PromptSessionClientAPI.client_pid_is_associated_with_session

Not related to this branch.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3382
https://mir-jenkins.ubuntu.com/job/mir-ci/491/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/325/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/351
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/343
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/343
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/334/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/334/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/334
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/334/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/334
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/334/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/334/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/491/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Alan:
>
> I have prototyped the set_logger approach but it does not work, for shared
> process reasons... If you think you can fix it, be my guest:
> https://code.launchpad.net/~mir-team/mir/fix-1546933-3/+merge/288056

I've investigated this a bit and the reason is not "shared process" but that
mcl::DefaultConnectionConfiguration::the_logger() is not "joined up" with ml::set_logger() and simply allocates its own logger.

So, what I've been thinking will work, doesn't. (I think that is wrong, but pre-existing.)

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> So, what I've been thinking will work, doesn't. (I think that is wrong, but
> pre-existing.)

...so I've created lp:1553219

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/52/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/354/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/57/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/384
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/376
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/376
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/363
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/363/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/363/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/363
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/363/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/363
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/363/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/363
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/363/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'tests/include/mir_test_framework/stub_client_connection_configuration.h' => 'include/test/mir_test_framework/stub_client_connection_configuration.h'
2=== renamed file 'tests/include/mir_test_framework/using_client_platform.h' => 'include/test/mir_test_framework/using_client_platform.h'
3=== modified file 'src/client/mir_connection.cpp'
4--- src/client/mir_connection.cpp 2016-03-02 16:35:02 +0000
5+++ src/client/mir_connection.cpp 2016-03-04 06:58:16 +0000
6@@ -352,9 +352,12 @@
7
8 try
9 {
10+ std::string name{spec.surface_name.is_set() ?
11+ spec.surface_name.value() : ""};
12+
13 stream = std::make_shared<mcl::BufferStream>(
14 this, request->wh, server, platform,
15- surface_proto->buffer_stream(), make_perf_report(logger), std::string{},
16+ surface_proto->buffer_stream(), make_perf_report(logger), name,
17 mir::geometry::Size{surface_proto->width(), surface_proto->height()}, nbuffers);
18 }
19 catch (std::exception const& error)
20
21=== modified file 'tests/acceptance-tests/CMakeLists.txt'
22--- tests/acceptance-tests/CMakeLists.txt 2016-02-26 14:45:41 +0000
23+++ tests/acceptance-tests/CMakeLists.txt 2016-03-04 06:58:16 +0000
24@@ -20,6 +20,7 @@
25 test_client_surface_swap_buffers.cpp
26 test_command_line_handling.cpp
27 test_client_surfaces.cpp
28+ test_client_logging.cpp
29 test_custom_window_management.cpp
30 test_custom_input_dispatcher.cpp
31 test_server_shutdown.cpp
32
33=== added file 'tests/acceptance-tests/test_client_logging.cpp'
34--- tests/acceptance-tests/test_client_logging.cpp 1970-01-01 00:00:00 +0000
35+++ tests/acceptance-tests/test_client_logging.cpp 2016-03-04 06:58:16 +0000
36@@ -0,0 +1,118 @@
37+/*
38+ * Copyright © 2016 Canonical Ltd.
39+ *
40+ * This program is free software: you can redistribute it and/or modify
41+ * it under the terms of the GNU General Public License version 3 as
42+ * published by the Free Software Foundation.
43+ *
44+ * This program is distributed in the hope that it will be useful,
45+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
46+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+ * GNU General Public License for more details.
48+ *
49+ * You should have received a copy of the GNU General Public License
50+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
51+ *
52+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
53+ */
54+
55+#include "mir_toolkit/mir_client_library.h"
56+#include "mir_test_framework/stub_client_connection_configuration.h"
57+#include "mir_test_framework/using_client_platform.h"
58+#include "mir_test_framework/connected_client_headless_server.h"
59+#include "mir/logging/logger.h"
60+
61+#include <gmock/gmock.h>
62+#include <gtest/gtest.h>
63+#include <string>
64+#include <sstream>
65+
66+using namespace testing;
67+using namespace mir_test_framework;
68+
69+namespace {
70+
71+class StringStreamLogger : public mir::logging::Logger
72+{
73+public:
74+ void log(mir::logging::Severity,
75+ std::string const& message,
76+ std::string const& component) override
77+ {
78+ ss << "[StringStreamLogger] "
79+ << component << ": " << message << std::endl;
80+ }
81+ // Awkwardly static. Because the instance is hidden in UsingClientPlatform
82+ static std::stringstream ss;
83+};
84+
85+std::stringstream StringStreamLogger::ss;
86+
87+struct Conf : StubConnectionConfiguration
88+{
89+ Conf(std::string const& socket)
90+ : StubConnectionConfiguration(socket)
91+ {
92+ }
93+ std::shared_ptr<mir::logging::Logger> the_logger() override
94+ {
95+ return std::make_shared<StringStreamLogger>();
96+ }
97+};
98+
99+struct ClientLogging : ConnectedClientHeadlessServer
100+{
101+ UsingClientPlatform<Conf> with_custom_logger;
102+ std::stringstream& client_log{StringStreamLogger::ss};
103+};
104+
105+} // namespace
106+
107+TEST_F(ClientLogging, reports_performance)
108+{
109+ TemporaryEnvironmentValue env("MIR_CLIENT_PERF_REPORT", "log");
110+ (void)env; // Avoid clang warning/error
111+
112+ auto spec = mir_connection_create_spec_for_normal_surface(
113+ connection, 123, 456, mir_pixel_format_abgr_8888);
114+ ASSERT_THAT(spec, NotNull());
115+ mir_surface_spec_set_name(spec, "Rumpelstiltskin");
116+ mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_software);
117+ auto surf = mir_surface_create_sync(spec);
118+ ASSERT_THAT(surf, NotNull());
119+ mir_surface_spec_release(spec);
120+
121+ int const target_fps = 10;
122+ int const nseconds = 3;
123+ auto bs = mir_surface_get_buffer_stream(surf);
124+ for (int s = 0; s < nseconds; ++s)
125+ {
126+ for (int f = 0; f < target_fps; ++f)
127+ mir_buffer_stream_swap_buffers_sync(bs);
128+
129+ std::this_thread::sleep_for(std::chrono::seconds(1));
130+ }
131+
132+ int reports = 0;
133+ while (!client_log.eof())
134+ {
135+ std::string line;
136+ std::getline(client_log, line);
137+ auto perf = line.find(" perf: ");
138+ if (perf != line.npos)
139+ {
140+ ++reports;
141+ char name[256];
142+ float fps;
143+ int fields = sscanf(line.c_str() + perf,
144+ " perf: %255[^:]: %f FPS,", name, &fps);
145+ ASSERT_EQ(2, fields) << "Log line = {" << line << "}";
146+ EXPECT_STREQ("Rumpelstiltskin", name);
147+ EXPECT_NEAR(target_fps, fps, 5.0f);
148+ }
149+ }
150+
151+ EXPECT_THAT(reports, Ge(nseconds-1));
152+
153+ mir_surface_release_sync(surf);
154+}

Subscribers

People subscribed via source and target branches