New issue
Advanced search Search tips

Issue 917197 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 8
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

Clean up MruWindowTracker

Project Member Reported by afakhry@chromium.org, Dec 21

Issue description

`MruWindowTracker::BuildMruWindowList()` and `MruWindowTracker::BuildWindowListIgnoreModal()` is called in many different places, sometimes several times per second, e.g. when window is being dragged (while updating shelf visibility). The code can be cleanup and streamlined. For example:

- BuildMruWindowList() (and others) `Bind()`s a repeating callback every time it's called to pass the predicate. This is not needed at all. [1]

- BuildWindowForCycleList() creates the list, then erases from it, where it could just pass the correct predicate from the beginning. [2]

- BuildWindowListInternal() Adds children of the switchable containers from all roots, then invokes the predicates to erase the ones that should be erased. But why add them in the first place? [3]

- The algorithm can be changed so that we don't have to reverse anything at the end. [4]

- `mru_windows_` is defined as an `std::list<>` [5], which is usually implemented as a doubly-linked list, in which each element node has *at least* [6] two pointers to the previous and next nodes. Being an `std::list<Window*>` (list of pointers) itself, hence our payload (Window*) is one third of the total node size (could be less). So it's a memory inefficient container for this particular use case, not to mention that it's bad for memory locality and doesn't take good advantage of CPU cache. `std::vector<>` is much better in this case.

[1]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#120
[2]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#129
[3]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#67
[4]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#97
[5]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.h#68
[6]: "At least" since it could be implemented such that the node contains other pointers and tracking elements.


 
Project Member

Comment 1 by bugdroid1@chromium.org, Jan 8

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a5b17a11248598a5cab4a08f2e117c952433a478

commit a5b17a11248598a5cab4a08f2e117c952433a478
Author: Ahmed Fakhry <afakhry@chromium.org>
Date: Tue Jan 08 18:57:19 2019

Cleanup MruWindowTracker

The code needed to be simplified and streamlined.
See bug description for detailed clean up points.

BUG= 917197 
TEST=Make sure MruWindowTrackerTest, and WindowCycleControllerTest
     in ash_unittests are still passing.

Change-Id: I01c79c7c84bd5ded783b54c132515b4571dfddd0
Reviewed-on: https://chromium-review.googlesource.com/c/1387456
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620821}
[modify] https://crrev.com/a5b17a11248598a5cab4a08f2e117c952433a478/ash/session/session_controller.cc
[modify] https://crrev.com/a5b17a11248598a5cab4a08f2e117c952433a478/ash/wm/mru_window_tracker.cc
[modify] https://crrev.com/a5b17a11248598a5cab4a08f2e117c952433a478/ash/wm/mru_window_tracker.h

Status: Fixed (was: Started)

Sign in to add a comment