Jeff Atwood wrote:
When I was on vacation last week, I took my cellular Nexus 7 with me so I could keep up with Discourse posts, here and on our partner sites.
Now:
- the Nexus 7 was never a super fast device even at launch
- it was released in the ancient days of 2012
- Discourse is a very intensive JavaScript application
So I wasn't exactly expecting barn-burning speeds.
I like using http://bbs.boingboing.net as a benchmark since it's our busiest site and I can go there any time of the day and many of the topics will consistently have new posts, and a lot of them are larger than the default post chunk size (20).
What I noticed was that Discourse performance was much worse than I remembered before on the Nexus 7. On a topic that has 20+ posts I saw this consistently:
- time to the "loading.." indicator: 2 seconds
- time to the topic loading a full 20 post chunk: 5 seconds
The Nexus 7 is substantially faster on small topics, where I'd see:
- time to the 'loading.." indicator: 2 seconds
- time to the topic loading 1 or 2 posts: 1 second
The majority of the performance problem comes in loading the posts, and seems to scale more or less linearly with the number of posts loaded in the topic, up to the maximum chunk size of 20.
But since many topics on BBS do have 20+ posts, it was excruciating to browse BBS and keep up with all the new posts on the Nexus 7 when I was paying a seven second penalty on every click. Brutal. Just brutal.
OK, so maybe the N7 is just old. Coincidentally, the new 2013 Nexus 7 was announced while I was on vacation. I immediately ordered 3 for the team and myself. It arrived literally the day I got back from vacation, this past Monday. It's easily twice as fast as the old model by every benchmark there is -- and it's plenty snappy in real world use!
So I excitedly unboxed the 2013 Nexus 7, updated it to latest over WiFi, and visited a large BBS topic, expecting a big free Moore's Law improvement:
- time to the "loading.." indicator: 2 seconds
- time to the topic loading a full 20 post chunk: 5 seconds
Err.. WTF? How can a 2x faster device have the same exact performance on Discourse as the old model? That's deeply concerning! We are building Discourse for the next decade of the Internet and we are assuming that newer devices will be faster. But this is exactly the same speed as the old device! How is that even possible, when every benchmark I read shows that the 2013 Nexus 7 is twice as fast as the 2012 model?
We did not see this with the iPad 3 and iPad 4, performance on Discourse scaled up with the device perfectly. I also noticed that the Surface RT, which is the same hardware as the Nexus 7, was not producing Discourse topic load times anything close to 7 seconds. It wasn't fast, exactly -- like I said the Tegra 3 hardware that the N7 and Surface RT are based on is not exactly speedy -- but it was much faster than the N7 in Discourse. Same hardware, different OS, different browser. I also tested with Firefox for Android and got the same exact numbers, even though (as far as I can tell) it is a completely different HTML and JS rendering engine.
This points toward Android as the problem.
Anecdotally, here are some rough load times observed on large, full-chunk (20 post) BBS topics on different devices:
- Nexus 7 (both) -- 2 sec load, 5 sec posts
- iPhone 5 -- 1 sec load, 2/3 sec posts
- iPad 4 -- 1 sec load, 2 sec posts
- Surface Pro -- instant load, 1 sec posts
Video demo of iPhone 5 vs Nexus 5 on the same Discourse pages:
The goal is for all devices to get to the Surface Pro (Intel i5) speeds over time, and I am confident that will happen in the next few years. However, if new Android devices are released and there's some crazy bottleneck we don't understand that prevents a JavaScript app like Discourse from scaling on new Android devices, that's.. a serious concern.
So @eviltrout spent the last few days looking in depth at this. The good news is he was able to increase N7 load times from 7 sec to 3-4 sec. But we have yet to find a "smoking gun" on Android that shows why, apparently, JavaScript performance is scaling so poorly to new devices.
I'll let him answer with details and pointers to the specific GitHub checkins.
We've heard that other devs have noticed poor JavaScript perf on Android devices -- does anyone have any specifics?
Posts: 59
Participants: 17