Live data from Hacker News

Why is the mobile web slow?

codenameone.com

11–20 of 48 posts

Re: Why is the mobile web slow?

#11

> Objective-C doesn't use methods like Java/C++/C#, it uses messages like Smalltalk. This effectively means it always performs late binding and invoking a message is REALLY slow in Objective-C. Well, "always" is a little wrong. The first time a message is passed and the bound method is called by the runtime is significantly slower (~4x slower than a virtual method call in C++). But then this message/method pair gets…

Java can inline many of virtual calls, making them essentially as fast as static methods (= much faster than C++ virtual methods).

Re: Why is the mobile web slow?

#12

> Objective-C doesn't use methods like Java/C++/C#, it uses messages like Smalltalk. This effectively means it always performs late binding and invoking a message is REALLY slow in Objective-C. Well, "always" is a little wrong. The first time a message is passed and the bound method is called by the runtime is significantly slower (~4x slower than a virtual method call in C++). But then this message/method pair gets…

Maybe this Objective-C optimization isn't implemented in iOS: http://www.shannah.ca/blog/?p=226

It really isn't that big of a deal. Trampolining is pretty straight forward and a caching of memory addresses isn't a big deal either. So I don't know why Apple wouldn't add this optimization to the iOS obj-c runtime.

Re: Why is the mobile web slow?

#13
post #6

The takeaway I got from this: DOM reflows are the major unsolvable source of perceived slowness. Cool. So, in an app where you avoid reflows, is mobile web fast? Why or why not? How avoidable are reflows? Can anyone point me to any articles that talk about this specifically, or benchmarks that make this concrete? (I vaguely recall benchmarks that covered reflow, but it's a vague memory).

Here's the first few hits from Google:

https://developers.google.com/speed/articles/reflow

https://developers.google.com/speed/articles/javascript-dom

http://www.stubbornella.org/content/2009/03/27/reflows-repai...

Re: Why is the mobile web slow?

#14
post #6

The takeaway I got from this: DOM reflows are the major unsolvable source of perceived slowness. Cool. So, in an app where you avoid reflows, is mobile web fast? Why or why not? How avoidable are reflows? Can anyone point me to any articles that talk about this specifically, or benchmarks that make this concrete? (I vaguely recall benchmarks that covered reflow, but it's a vague memory).

Maybe this will help: https://developers.google.com/speed/articles/reflow

Edit: ah, posting the same link at the same time... But I think the best tip is: be shallow. A lot of things trigger reflow but DOM-depth is causing slow reflows.

Re: Why is the mobile web slow?

#15

> Don't allocate when you need fast performance. This is good practice regardless of whether you are using a GC since allocation/deallocation of memory are slow operations (in fact game programmers NEVER allocate during game level execution). > This isn't really hard, you just make sure that while you are performing an animation or within a game level you don't make any allocations. The GC is unlikely to kick in and…

That's true. The article however, does state that a GC stall is bad but explains it can be avoided with a good GC and a good programmer. With ARC you get more consistent performance but the article was going after the claim that GC inherently require 5 times more RAM to be reasonably performant.

Re: Why is the mobile web slow?

#16

> Don't allocate when you need fast performance. This is good practice regardless of whether you are using a GC since allocation/deallocation of memory are slow operations (in fact game programmers NEVER allocate during game level execution). > This isn't really hard, you just make sure that while you are performing an animation or within a game level you don't make any allocations. The GC is unlikely to kick in and…

Great, I gotta write (as if) in FORTRAN :-)

Hey, I said "might"!

Re: Why is the mobile web slow?

#17
post #14
post #6

The takeaway I got from this: DOM reflows are the major unsolvable source of perceived slowness. Cool. So, in an app where you avoid reflows, is mobile web fast? Why or why not? How avoidable are reflows? Can anyone point me to any articles that talk about this specifically, or benchmarks that make this concrete? (I vaguely recall benchmarks that covered reflow, but it's a vague memory).

Maybe this will help: https://developers.google.com/speed/articles/reflow Edit: ah, posting the same link at the same time... But I think the best tip is: be shallow. A lot of things trigger reflow but DOM-depth is causing slow reflows.

[deleted]

Re: Why is the mobile web slow?

#18

> Objective-C doesn't use methods like Java/C++/C#, it uses messages like Smalltalk. This effectively means it always performs late binding and invoking a message is REALLY slow in Objective-C. Well, "always" is a little wrong. The first time a message is passed and the bound method is called by the runtime is significantly slower (~4x slower than a virtual method call in C++). But then this message/method pair gets…

Another good discussion of objc_msgSend() is:

http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-th...

Re: Why is the mobile web slow?

#19
post #9

"They can also reallocate elements into the stack frame rather than heap when they detect specific allocation usage." I've always been interested in whether this is done in various managed languages. Since I never know the answer, one pattern I've taken to is to allocate memory in static const/final fields that I would normally put on the stack in C, instead of doing a heap allocation to a variable whose scope is com…

Java does this a whole bunch, it's decently easy for compiler writers to implement and it gets a good speedup on most benchmarks.

Re: Why is the mobile web slow?

#20
> This isn't really hard, you just make sure that while you are performing an animation or within a game level you don't make any allocations.

That seems like a big 'just', at least in a multi-threaded application...

Post reply on HN