Week 7

This document summarizes the work being done in week 7. This week, I worked on the browser extension for tab management again.

1 Metric

The basic idea was to use the data from TabUseProf described two weeks ago to discard tabs which are not in-use. After looking at tab use patterns for a while, I came up with a metric to do the same. Here's how the metric runs:

  • Every 1 second, an attempt to discard tabs is made.
  • Tabs that are immune to destruction are tabs which are active, tabs which have audio playing, tabs which are loading, tabs which are already discarded, and tabs which are pinned. If the number of tabs, excluding these tabs, is more than 8, we discard one tab.
  • What tab is discarded depends on how much points the tab has.
  • Each tab starts out with 5 points when created/brought back from a discarded state.
  • For every use of the tab, it gets 5 points if the usage exceeds 5s, and then 1 point every 5s for every second after that. Points are doubles, they need not be integral.
  • For every minute that the tab is not in use, its points are halved (this is a constant process, not a one time halving).

2 Usage

The basic usage instructions are the same as last time. I've attached the extension, which you need to side-load according to these instructions. I'm able to load it just by clicking it, however, so make sure to try that first.


Once done, browse for a while, before clicking the button on the toolbar (a green jigsaw puzzle piece, which says "See TabUseProfPage"). It should be very similar to last time, but now you can see the tabs which have been discarded (they are marked as "suspended").


3 Measuring CPU/Memory Usage

The standard tool for this is htop, or top, however, I found it very handy to use a python based tool to plot a memory usage graph instead of relying on top and manually parsing the data myself, so I've included that here as well.

$ pip install psrecord
$ pip install matplotlib
$ psrecord <pid of main firefox process> --include-children --plot plot.png

The output will be something of this sort:


Author: Milind Luthra

Emacs 25.3.1 (Org mode 8.2.10)