Week 5

This document summarizes work done/being done in week 5. This was the midsem week, so I did not have so much time. Instead of continuing with the usual work, I decided to explore one of the ideas I'd discussed with sir in passing earlier.

1 Browser Memory

The issue was one of browser memory - that keeping tabs open for a long time in a browser can cause the whole system to slowdown, because the tabs consume so much memory even if they're not actively in use. I decided to find ways in which I could profile my memory use and see if I could do anything about it. I'm using the Nightly version of Firefox, but this should work for any version, and the later extension should be easy to modify to run in any browser (since it follows the WebExtension standards).

2 Gecko Profiler


My first attempt to profile was to use the Gecko Profiler addon, which is a WebExtension using the privileged "geckoProfiler" API. I had used this earlier to profile operations IO on the main thread which had slowed down the browser. As far as I could tell (the profiler is quite complicated, I do not understand it completely) the profiler gives me the usage for each of the processes that Firefox is using (there is a main process, several content processes, etc), instead of giving me a tab-wise memory usage. Thus I decided to write my own extension to profile tab usage.

3 TabUseProf

Instead of focusing on tab memory usage, I decided to focus on tab usage instead ("live" tabs vs open tabs). I have often noticed that my tab usage (and several of my friends') falls into the following categories:

  • Permanently open tabs (IRC, Slack, YouTube). I pin these tabs.
  • Reference/current tabs. These are the ones open in the browser that I refer to often enough. They are open (and useful) for the entire duration of my session.
  • One-time use tabs. These are the ones I open and never close. Most commonly include StackOverflow answers etc. Sometimes, when I have a lot of tabs open, it is tedious to scroll over the tab strip to close any tabs, so I simply stop closing any tabs at all.

The current target is to profile tabs, and see if the categories I have described are useful. 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").

The profiler will output something of this sort, depending on your usage.


4 Using TabUseProf to Profit

The main purpose of this profiler is to look at how we use tabs, and once we have enough information, start discarding tabs which are not likely to be used again. There is a discard API provided by the webextensions standard which I will use for this purpose.

Currently, the measure used by the profiler will be the number of times (and the length of times) a tab is used and the last use time, but I also wanted to add how much memory a tab is using. Unfortunately, there's no API for this right now, there's ongoing work for it. So, I'll eventually be able to add it. I also tried using the "geckoProfiler" permission, but that involved jumping through quite some hoops, and the data it made available was not exactly the one I needed.

Author: Milind Luthra

Emacs 25.3.1 (Org mode 8.2.10)