Home Page

Tips page

University Page

Programming

Debian & Linux

Some works

About me

Del.icio.us Bookmarks

BOINC Combined Statistics

Site Statistics

Contact me sending an e-mail (antispam defense activated)

debian

hacker emblem

blogger

GeoURL

View Sandro Tosi's profile on LinkedIn

This is my Google PageRank

GMail is increasing mailboxes size...

GMail is increasing mailboxes size

1. Introduction

As many users have noticed, GMail decided to celebrate its first anniversary starting incrementing its mailboxes size.

I've write a simple Java program to display the progression in incrementing size (or better, to understand the code googlers have coded). But more info is just here below...

2. It is written in the code...

Going to the main page of GMail, you can see a real-time counter of megabytes available in storage. How do they update that counter? Hey, man, it is written in the code!! And so, let's take a look at this:

function el(id) {
if (document.getElementById) {
return document.getElementById(id);
} else if (window[id]) {
return window[id];
}
return null;
}

var CP = [
[ 1112439600000, 2050 ],
[ 1113062400000, 2075 ],
[ 1113685200000, 2100 ]
];

(...)

function updateQuota() {
if (!quota) {
return;
}

var now = (new Date()).getTime();
var i;
for (i = 0; i < CP.length; i++) {
if (now < CP[i][0]) {
break;
}
}
if (i == 0) {
setTimeout(updateQuota, 1000);
} else if (i == CP.length) {
quota.innerHTML = 'Over ' + CP[i - 1][1];
} else {
var ts = CP[i - 1][0];
var bs = CP[i - 1][1];
quota.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs);
setTimeout(updateQuota, 50);
}
}

var PAD = '.000000';

function format(num) {
var str = String(num);
var dot = str.indexOf('.');
if (dot < 0) {
return str + PAD;
} if (PAD.length > (str.length - dot)) {
return str + PAD.substring(str.length - dot);
} else {
return str.substring(0, dot + PAD.length);
}
}

(... inside html code ...)

< span id=quota>Over 2000< /span> megabytes (and counting) of free storage so you'll never need to delete another message.< /font>< /p>
(...)
< script>
< !--
quota = el("quota");
updateQuota();
// -->
< /script>

(I've extracted only the relevant parts.)

The array CP defines the size (second column) of a mailbox at a given time (the first column). The function updateQuota() does all the work for counter.

First of all, it tests the time-frame in respect to CP and sets i to the corresponding line of CP: if now is less than every time in the array, than waits another second for more lucky; if now is over every time in the array, than simply update the code of quota; if none of the above cases happened, than starts the interesting part.

At this point, we can be sure that now is between i and i-1; starting from that, updateQuota() calculates the size of the mailboxes following a linear growth from CP[i-1] to CP[i], updating the counter every 50ms.

Note that I've done nothing different from reading the code of the GMail home page.

3. and counting...

At today, the progression is (funny is how much they like April 1st: GMail was released on that day on 2005 and it remains in the inner "heart" of how's behind it):

Fri Apr 01 06:00:00 GMT+01:00 2005, 1025 Mb
Sat Apr 02 12:00:00 GMT+01:00 2005, 2050 Mb
Sat Apr 09 17:00:00 GMT+01:00 2005, 2075 Mb
Sat Apr 16 22:00:00 GMT+01:00 2005, 2100 Mb
Sun Apr 24 03:00:00 GMT+01:00 2005, 2125 Mb
Sun May 01 08:00:00 GMT+01:00 2005, 2150 Mb
Wed Jun 01 08:00:00 GMT+01:00 2005, 2250 Mb
Fri Jul 01 08:00:00 GMT+01:00 2005, 2350 Mb
Mon Aug 01 08:00:00 GMT+01:00 2005, 2450 Mb
Thu Sep 01 08:00:00 GMT+01:00 2005, 2550 Mb
Sat Oct 01 08:00:00 GMT+01:00 2005, 2650 Mb
Sun Jan 01 09:00:00 GMT+01:00 2006, 2680 Mb
Thu Jun 01 08:00:00 GMT+01:00 2006, 2730 Mb
Mon Jan 01 09:00:00 GMT+01:00 2007, 2800 Mb
Sun Apr 01 09:00:00 GMT+01:00 2007, 2835 Mb
Tue Apr 01 08:00:00 GMT+01:00 2008, 2980 Mb
Wed Apr 01 08:00:00 GMT+01:00 2009, 3125 Mb
Thu Apr 01 08:00:00 GMT+01:00 2010, 3270 Mb
Fri Apr 01 08:00:00 GMT+01:00 2011, 3415 Mb
Sun Apr 01 08:00:00 GMT+01:00 2012, 3560 Mb

4. Work hard, work fast...

GMail programmers work vary fast make it a nice service. So something has changed: now (about after Saturday 16 April) array CP has only two values

var CP = [
[ 1112439600000, 2050 ],
[ 1114308000000, 2125 ]
];

and the function updateQuota() has been changed this way:

...

} else {
var ts = CP[i - 1][0];
var bs = CP[i - 1][1];
quota.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs);
setTimeout(updateQuota, 1000); <---
}

...

the change is in the timeout after the update of capacity; this leads to a "less flickering" counter.

5. A graph is better than 1000 words

Would you believe me if i say that the GMail grow is linear with time? I don't know, so I plot a graph:

To create this graphic I've used Octave, a powerful tool similar to MatLab. Values are taken from the last CP array:

var CP = [
[ 1114930800000, 2150 ],
[ 1117609200000, 2250 ]
];

and the code I've used is:

time=1114930800000:100000:1117609200000;
ts=1114930800000;
bs=2150;
tf=1117609200000;
bf=2250;
size=( ( time-ts ) / ( tf - ts ) * ( bf - bs ) ) + bs;
plot( time, size );

If you can remember something from high school math, the growth is linear because ( time-ts ) / ( tf - ts ) factor it's a linear function of time, modified only by constants (so that the trend is not modified).

6. Linear no more

Google could be huge, but it's not infinite: GMail size could not grow as fast as in first stages. This is how size evolves during time:

As previous one, even this is crafted with Octave, with following istructions:

gmail=[
1112331600000, 1025
1112439600000, 2050
1113062400000, 2075
1113685200000, 2100
1114308000000, 2125
1114930800000, 2150
1117609200000, 2250
1120201200000, 2350
1122879600000, 2450
1125558000000, 2550
1128150000000, 2650
1136102400000, 2680
1149145200000, 2730
1167638400000, 2800
1175414400000, 2835
1207033200000, 2980
1238569200000, 3125
1270105200000, 3270
1301641200000, 3415
1333263600000, 3560
];

plot(gmail(:,1), gmail(:,2));

title('GMail size growth, full time analysis');
xlabel('Time, in ms (Java way)');
ylabel('Size, in Mb');
legend('Size',2);

After a real fast growth in intial phases, mailboxes size starts to grow slower, and these days even slower. What said is valid at time of writing, 29 April 2006.

Every question, suggestion or others are welcome!


Sandro Tosi (email).
Created: 10 April 2005; Last Updated: 10 September 2007