Tuesday, October 30, 2007

New Gmail infrastructure launches! Congrats to Dan!

Whee.. the new Gmail frontend is launched.

When Dan joined the company two years ago, I didn't know what to expect. I only really knew him from his work on Thirteenth Parallel and from talking to him on dhtmlcentral.com.

I was worried for his sanity when he got assigned to Gmail, because it is one of the oldest and biggest JavaScript applications at Google. Therefore it was also the most, err, crufty :).

I offered to try and help him transfer to a newer project, but surprisingly, Dan did not want to leave. He dove in to the cruft, initially on Gmail Chat, but over time more and more on core Gmail. He began agitating for change, which culminated in this new design.

At Google, we dogfood all our products. That means, among other things, that we use Gmail all day for all our internal mail. I don't know of any other company producing web mail that can claim that. It also means that we have really high standards for these products. 500ms latency is usually considered great for a web application, but for something you use all day, it just won't cut it. Because of this, the Gmail team has been to hell and back several times over the course of this project, trying to shave milliseconds off frequent operations.

As one small example, one team member reverse-engineered jscript.dll to figure out how its GC algorithm worked, and was horrified to find that it had hard-coded, arbitrary limits on how many objects could be allocated before a GC would occur. This led to an insane amount of effort optimizing the code to reduce the number of allocations in core code paths.

Congratulations to the team! I'm really looking forward to the new features this design enables.

16 comments:

Anonymous said...

Not sure that breach of licence is something I would admit to in a public place.

Anonymous said...

What developer worth his salt HASN'T tinkered/decompiled MS assemblies from time to time? It's par for the course when you work with MS systems.

Anonymous said...

"Not sure that breach of licence is something I would admit to in a public place."

Maybe because you are chicken.

You must realize, this is not your blog. I for one am glad that people use their brainpower and time to detect and show potential pitfalls or "design decisions", which may give other people the ability to understand where a problem lies ... in this case, I wonder why it was hardcoded. Hardcoding really almost always gives you less flexibility.

Anonymous said...

I'm not a lawyer so I don't know the impact, but from http://www.microsoft.com/technet/prodtechnol/ie/ieak7/eula.mspx

"You may not
-snip-
• reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;"

Unknown said...

I am not a lawyer but 90% of the EULA is not legally enforceable anyway. It has been and always will be legal to reverse engineer anything you like in America. They can say you can't to try to dissuade you but you don't have to (and shouldn't) listen.

Dave Methvin said...

Did you try calling CollectGarbage()?
You can even call it on a timer if need be. There's an example on the MSKB that does so.

Dan said...

The problem is the GC running too often and wasting hundreds of milliseconds.

And thanks Aaron :) I wanted to point out that I'm just a cog. The team working on this have been wicked!

Brandon Titus said...

Great work on the site! SOOO much faster than before.

By the way, are you having any problems with Safari over at Google? For some reason, I couldn't access Gmail and, at times, Google at points during the day.

Garrett said...

Aaron,

So you have some optimizations based on an alleged rev eng of JScript dll, huh?

Cool.

How about showing us what you uncovered? I'd really like to see it.

So you interviewd Dan, huh? Just curios: Did you disguise identity to him? I mean, did you act like you didn't know him from DHTML Central? Or am I special?

BTW - regarding the questions you asked me in the interview: Listener, wow, I'm glad I really told you it was inspired by "Aaron Boodman" in the interview. Didn't know you were Aaron Boodman, but I remember you were smiling. Remember, you asked me where I got inspiration from that code.

As my understanding of JavaScript has increased, I realize how misleading the variable names and comments in the original code were! that really caused a lot of confusion, mostly the __scope__ variable. That very code plagues Dojo currently, but I've since learned what scope really is.

BTW, you mentioned many years ago on dhtmlcentral that you wanted to "be my friend." Remember, you posted pics of your BMW. Remember?

Well, I mailed you when I was in Queens. Did you get that mail? I mailed you a few times after the interview, too. Did you get those? I'm here in MTN View now, listenening to Pantera, sitting in my Honda, right here on Castro St.

Garrett

boots said...

Hi Garrett,

I definitely remember your interview! How could I forget being shown my own code as an example of a candidate's past work? That was priceless. You're right though -- it was a very good thing that you admitted it was "inspired by" someone else when pressed.

As for the variable names, yep, they were wrong. My bad. I'm glad that you were finally able to decipher the code.

Oh, and, Pantera? Seriously?

Garrett said...

@Aaron
-"How could I forget being shown my own code as an example of a candidate's past work?"

You weren't shown your own code, you were shown my code, and that is a small aspect of the program.

If that is what the interview notes included, then that should be corrected. I do not appreciate being misrepresented here, or in your company, or anywhere.

How could you not remember your own code? I showed you why I did not want to use eval in my code, remember? We discussed this, even, and you were actually arguing why it was OK to use eval for IE. Remember? It was different code, but used a similar method signature.

You should not put me down for saying that I used your code and pushed it off as my own. That is called a Straw Man.

The code that I did use in that example that was not my own was Dean Edward's CssQuery. I have never tried to hide that fact, and you can see the very program that I showed to you is right here:
http://dhtmlkitchen.com/scripts/draglib/DragModule/demo/csseditor/tabsdemo/index.html

Now I'm sorry I did not effectively communicate the intent of the program. I generally like being able to explain my code to people who can understand it.

I'll try and give a gist of what this things' about. This is the program that I showed you in the interview:

The CSS Editor allows a user to edit the stylesheet visually. It's intended as CMS plug in.

It accomplishes its goal by drawing an association between a style rule (1) and page elements (n).

When the user selects an element, the editor is enabled with the most specific matching selector in the stylesheet. The user can then edit the style properties through the graphical interface.

The editor has 3 states: enabled, disabled, and save. I used the State pattern to manage this; as the user might do different things while using the editor.

I used Factory to initialize the editor components (B,I,U, Text-Align, Border, Color, et c).

When the user is done editing, s/he can save the work to the server, using XHR. This is useful because it allows the user to update an entire site, separately from the content.

The init method uses the Factory. Components all conform to an interface, making possible the undo/redo Command pattern.

Each component's element has the className "component", plus something else, like "button", to indicate what type of component it is. The component also has an ID that represents what style property it edits, e.g. id="background-color", id="text-align"

It is still not finished, and it's a lot to explain in this tiny text area.

If nothing else, check out the color selector (remember, I showed you in the interview). It uses png overlays to mimic the HSV picker in photoshop, scaled to half size (fits better).

Now, I originally returned to this post to mention something I thought would be helpful to you and Dan (and also to see if you answered any of my questions, but I guess I can forget about that, huh?).

I'm going to go ahead with that anyway, just because I use GMAil and I'm annoyed by the bug.

I found that when I try to save a draft, and save fails due to no connection, and then I reconnect, I cannot save the draft because the save button does not become enabled again. It used to not do this.

It's the same bug that Groups has. Take a look at the source code for http://groups.google.com/ and see what's going on. Specifically, when you click the submit button, it disables, but does not ever become reenabled.

This is bad U/X because the user (I) have to copy the text. For Groups, I have to reload the page.

For Mail, I have to click "drafts" and navigate to right one. GMail prompts me "do you want to navigate away from unsaved changes?", but doesn't give me an option to save. Just like Groups does.

I am not listening to Pantera now, but just got done listening to Slayer after leaving the gym. Good, honest, heavy music. I would not expect you to understand.

Well I've got most of your questions answered, I think.

Garrett said...

THE FULL URL:
http://dhtmlkitchen.com/scripts/draglib/DragModule/demo/csseditor/tabsdemo/index.html

This is not your code; your code was never used on this project, and even though the original code I had was not good, it was not the main point of the program.

Garrett said...

Wow, blogger keeps chopping off the url. Great. Here it is on two lines:

http://dhtmlkitchen.com/scripts/draglib/DragModule/demo/csseditor/tabsdemo/index.html

I'm trying using an a tag this time.

John said...

Why does this new Gmail randomly hang when using a Mac?
I have a MacBook pro and Firefox and have never had this happen before with Gmail.
The only way out is to force quit the browser and go back to the previous version of Gmail.

Garrett said...

2 posts down:
Aaron:
"But the eval line does not work in IE. In IE, eval() always runs in the calling scope, no matter where you get the function."

It looks like when Aaron says scope, he really means execution context.

Anonymous said...

Hello Aaron!
I tried to use your Transmenu script and I have a trouble:
when I paste in the beginning of my HTML document string "!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional"... and so on, page not working with Firefox!!!
when I paste this string after HTML tag, everything is OK but IE is disolaying drop-downs incorrect.
Could you help me?
aknyrik@blitz.kiev.ua