DWR

Poor performance in IE due to bad string concatenation

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.rc3, 2.0.rc4, 2.0.rc5, 2.0, 2.0.1, 2.0.2, 2.0.3, 3.0.M1
  • Fix Version/s: 2.0.4, 3.0.RC1
  • Component/s: Engine
  • Description:
    Hide
    In IE 5, 6 and 7, when passing up large javascript objects to the server, it takes ages to finish (I am speaking about more than 5 minutes here) whereas it is very fast in FireFox (a few seconds).
    This problem was raised a year ago in the following thread : http://www.nabble.com/Poor-client-side-performance-in-engine.js-to8310543.html#a8310543

    As exposed in this thread, the problem comes from the way the query string is built :
    query += prop + "=" + batch.map[prop] + "\n";

    The "+=" construct is terribly slow in IE, and it would be better to use directly an array or a javascript implementation of a StringBuffer.




    Show
    In IE 5, 6 and 7, when passing up large javascript objects to the server, it takes ages to finish (I am speaking about more than 5 minutes here) whereas it is very fast in FireFox (a few seconds). This problem was raised a year ago in the following thread : http://www.nabble.com/Poor-client-side-performance-in-engine.js-to8310543.html#a8310543 As exposed in this thread, the problem comes from the way the query string is built : query += prop + "=" + batch.map[prop] + "\n"; The "+=" construct is terribly slow in IE, and it would be better to use directly an array or a javascript implementation of a StringBuffer.

Activity

Hide
Mike Wilson added a comment - 08/Apr/08 1:53 PM

Unfortunately it's not as simple as just using array.join everywhere. For the type of string building we do, string+= is actually faster than array joining in all browsers except IE, but in IE it makes a huge difference.

Even in IE it is faster to use string+ for building small strings than to use an array.

So the fix I have checked in uses array.join in IE only, and only for areas in the code where large strings are handled. This has put IE performance on par with FF performance (a little bit slower though).

Show
Mike Wilson added a comment - 08/Apr/08 1:53 PM Unfortunately it's not as simple as just using array.join everywhere. For the type of string building we do, string+= is actually faster than array joining in all browsers except IE, but in IE it makes a huge difference. Even in IE it is faster to use string+ for building small strings than to use an array. So the fix I have checked in uses array.join in IE only, and only for areas in the code where large strings are handled. This has put IE performance on par with FF performance (a little bit slower though).

People

Dates

  • Created:
    22/Feb/08 3:32 PM
    Updated:
    08/Apr/08 1:53 PM
    Resolved:
    08/Apr/08 1:53 PM