Merge lp://staging/~ted/ubuntu-app-launch/lp1579799-oom-adjust into lp://staging/ubuntu-app-launch/16.10

Proposed by Ted Gould
Status: Merged
Approved by: dobey
Approved revision: 303
Merged at revision: 243
Proposed branch: lp://staging/~ted/ubuntu-app-launch/lp1579799-oom-adjust
Merge into: lp://staging/ubuntu-app-launch/16.10
Prerequisite: lp://staging/~ted/ubuntu-app-launch/abi-compliance
Diff against target: 3445 lines (+1737/-729)
29 files modified
CMakeLists.txt (+11/-3)
debian/control (+5/-5)
debian/libubuntu-app-launch3.install (+1/-1)
debian/libubuntu-app-launch3.shlibs (+1/-1)
helpers-shared.c (+1/-1)
helpers.c (+17/-8)
libubuntu-app-launch/CMakeLists.txt (+5/-1)
libubuntu-app-launch/app-info.h (+7/-1)
libubuntu-app-launch/application-impl-base.cpp (+463/-111)
libubuntu-app-launch/application-impl-base.h (+52/-5)
libubuntu-app-launch/application-impl-click.cpp (+30/-0)
libubuntu-app-launch/application-impl-click.h (+4/-0)
libubuntu-app-launch/application-impl-legacy.cpp (+37/-1)
libubuntu-app-launch/application-impl-legacy.h (+7/-0)
libubuntu-app-launch/application-impl-libertine.cpp (+28/-0)
libubuntu-app-launch/application-impl-libertine.h (+5/-0)
libubuntu-app-launch/application.cpp (+39/-0)
libubuntu-app-launch/application.h (+13/-0)
libubuntu-app-launch/libubuntu-app-launch.map (+1/-0)
libubuntu-app-launch/oom.h (+54/-0)
libubuntu-app-launch/registry-impl.cpp (+318/-0)
libubuntu-app-launch/registry-impl.h (+21/-2)
libubuntu-app-launch/registry.cpp (+61/-21)
libubuntu-app-launch/second-exec-core.c (+3/-10)
libubuntu-app-launch/second-exec-core.h (+2/-2)
libubuntu-app-launch/ubuntu-app-launch.cpp (+129/-462)
tests/CMakeLists.txt (+1/-0)
tests/libual-cpp-test.cc (+357/-74)
tests/libual-test.cc (+64/-20)
To merge this branch: bzr merge lp://staging/~ted/ubuntu-app-launch/lp1579799-oom-adjust
Reviewer Review Type Date Requested Status
dobey (community) Abstain
unity-api-1-bot continuous-integration Needs Fixing
Charles Kerr (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+302321@code.staging.launchpad.net

This proposal supersedes a proposal from 2016-05-19.

Commit message

Add API to allow adjusting of the OOM score for an application instance

Description of the change

This branch is a bit of refactoring in that it moves the PID setting code from the C side to the C++ to add the new API. A lot of converted code that has been made more generic to accommodate the new use-cases. Then the C interface has been adjusted to call into the C++ code that implements the functionality.

The new code implements a way to set the OOM value for an instance. It uses a psuedo-enum style so that we can try to keep the states contained while still having a flexible system for experimentation.

A nice improvement in this code as that we're no longer using the ZG global log file so we don't have a memory leak from it if the registry is deallocated. Also the ZG event and DBus signalling now happen outside of the calling thread, which should improve the responsiveness of Unity8 (probably only slightly).

This branch does need a patch to ZG, specifically bug 1584849, which we will land in the same silo.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

API looks good!

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

comments inline

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal
Download full text (6.3 KiB)

On Tue, 2016-05-24 at 19:36 +0000, Charles Kerr wrote:
> >  # Deprecated needed for g_atexit() in libual
> > -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-
> > error=unused-function -Wno-error=deprecated-declarations
> > -std=gnu99")
> > -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11
> > -pthread")
> > +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-
> > error=unused-function -Wno-error=deprecated-declarations -std=gnu99
> > -g")
> > +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11
> > -pthread -Wno-error=deprecated-declarations -g")
> Better way to do this is add_compile_options()
Okay, learned a bit. r254
> > /* Query lifecycle */
> > bool isRunning() override
> > {
> > - return ubuntu_app_launch_get_primary_pid(_appId.c_str()) != 0;
> > + return ubuntu_app_launch_get_primary_pid(std::string(appId_).c_str()) != 0;
> >

>
> "return primaryPid() != 0;" ?
>

Good idea! r253
> > - vector.push_back(static_cast<pid_t>(GPOINTER_TO_INT(list->data)));
> > + vector.push_back(static_cast<pid_t>(GPOINTER_TO_INT(pntr->data)));
> >

>
> Sneaky bugfix ;)
No comment :-)
> > /* Manage lifecycle */
> > void pause() override
> > {
> > - ubuntu_app_launch_pause_application(_appId.c_str());
> > + registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT);
> > +
> > + auto oomstr = std::to_string(static_cast<std::int32_t>(oom::paused()));
> > + auto pids = forAllPids([this, oomstr](pid_t pid) {
> >

>
> better to capture oomstr by reference to avoid a temp copy
>

I think that the compiler should move it in that case because there's
no other usage, but to ensure I changed it (not gonna ready the asm to
prove it either way :-) ) r255
> > + auto serror = std::shared_ptr<GError>(error, g_error_free);
> > + throw std::runtime_error("Unable to access OOM value for '" + std::string(appId_) + "' primary PID '" +
> > + std::to_string(pid) + "' becuase: " + serror->message);
> >

>
> because
r256
> > + }
> > +
> > + auto score = static_cast<oom::Score>(std::atoi(content));
> >

>
> Bounds checking for [-1000..1000]?
Kinda felt like the kernel was doing that for us... seems we should be
able to depend on it?
> > - std::string _appId;
> > + AppID appId_;
> >

>
> const
>

r257
> > + {
> > + std::map<pid_t, bool> seenPids;
> >

>
>
> This would be better as a std::set. For example:
>
> std::set seenPids;
>
> bool added_any;
> do
> {
> added_any = false;
> auto pidlist = pids();
> for (auto& pid : pidlist)
> {
> if (seenPids.insert(pid).second)
> {
> eachPid(pid);
> added_any = true;
> }
> }
> }
> while (added_any);
>
> return std::vector(seenPids.begin(), seenPids.end());
Cool, good improvements. I kept the while instead of the do/while
because I think they confuse people as they're used so infrequently.
 r258
> > + if (G_UNLIKELY(procpath.empty()))
> > + {
> > + /* Set by the test suite, probably not anyone else */
> > + ...

Read more...

Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

Thanks for the changes, ted!

review: Approve
Revision history for this message
Charles Kerr (charlesk) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:297
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/7/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/122/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/130
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/77
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/77
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/77
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/60/console
    ABORTED: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/60/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/7/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

This good to land then?

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:298
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/20/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/281/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/287
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/221
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/221
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/221
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/150/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/150/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/20/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) wrote : Posted in a previous version of this proposal

Currently failing to build. Think we also need to examine this to see how much we can split it up to smaller branches.

review: Needs Fixing
Revision history for this message
Ted Gould (ted) wrote :

This is the branch that needs the ZG fix to have the tests pass. Also, it has already been reviewed so I see no reason to split it up further.

Added the ABI tests which showed it is an ABI break, so added that in here.

Revision history for this message
dobey (dobey) wrote :

Can we split any of this out into smaller branches at all?

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

On Mon, 2016-08-08 at 17:40 +0000, Rodney Dawes wrote:
> Can we split any of this out into smaller branches at all?
I think that effort would make sense to make it easier to review, but
since it has already been reviewed, I think at this point that effort
isn't warranted.

Revision history for this message
dobey (dobey) wrote :

> On Mon, 2016-08-08 at 17:40 +0000, Rodney Dawes wrote:
> > Can we split any of this out into smaller branches at all?
> I think that effort would make sense to make it easier to review, but
> since it has already been reviewed, I think at this point that effort
> isn't warranted.

It's not just about making it easier to review.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:301
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/44/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/318/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/324
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/251
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/251
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/251
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/180/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/180/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/44/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve
Revision history for this message
dobey (dobey) wrote :

This needs split up into smaller changes. The ZG related fixes which are unrelated to OOM don't belong in this branch. The branch does not follow the style guidelines https://unity.ubuntu.com/wp-content/uploads/2012/03/cppguide.html#Formatting

review: Needs Fixing
Revision history for this message
Ted Gould (ted) wrote :

Please stop changing the status of this merge request. As stated earlier, I am not going to break it up into smaller branches. Sorry if that offends you.

Revision history for this message
dobey (dobey) wrote :

Well I'm sorry someone reviewed your giant mega branch 6 months ago and was a bit more lax about it, and then it sat around forever and you're using that as an excuse that it's already been reviewed, but I reviewed it and found problems and is not appropriate for landing into the tree in its current state. Sorry if that offends you.

302. By Ted Gould

Backport timeout non-thread default fix from snappy branch

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:302
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/53/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/388/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/394
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/309
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/309
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/309
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/239/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/53/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Reapproving to include r302 which ensures callbacks get called in the right thread context.

review: Approve
303. By Ted Gould

Pulling through eventually test updates

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:303
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/55/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/392/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/398
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/313
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/313
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/313
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/243/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/243/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/55/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Abstain

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