Search code examples
performancefirefoxyui

Y.DataSchema.JSON.apply() performance problems in FireFox


I am calling:

Y.DataSchema.JSON.apply( { ... }, "..." )

against a large complex JSON string -- 275K in size, with elements nested four levels deep. Additionally, some of the parsers in the schema also call Y.DataSchema.JSON.apply().

In Chrome and IE8, this call takes less than 0.5 sec. In FF, about 4 seconds!

Any ideas why there is such a drastic performance difference, and what I can do about it? More details below.

Thanks, DC


Details:

  • YUI version 3.7.3
    • I just tried with latest version 3.10.3 -- no significant changes.
  • FF version 21, with FireBug 1.11.4
  • In the call below, rtnData is about 275K long, and fits the schema perfectly. It is impractical to include it here.
  • The full call is:

    thisBlock._data = Y.DataSchema.JSON.apply( {
        resultListLocator: 'attendanceResults.clients.items',
        resultFields: [
            { key: "activityOccurrenceLocationId", locator: 'attendanceDetails._attributes.activityOccurrenceLocationId' },
            { key: "startDate", locator: 'attendanceDetails._attributes.startDate', parser: DT.jsonParser.date },
            { key: "endDate", locator: 'attendanceDetails._attributes.endDate', parser: DT.jsonParser.date },
            { key: "isisClientId", locator: "_attributes.isisClientId" },
            { key: "personId", locator: "_attributes.personId" },
            { key: "salutation", locator: "salutation" },
            { key: "firstName", locator: "firstName" },
            { key: "lastName", locator: "lastName" },
            { key: "teamId", locator: "team._attributes.attendanceTeamId", parser: DT.jsonParser.integer },
            { key: "teamName", locator: "team.attendanceTeamName" },
            { key: "transportation", locator: "plannedTransportation.items" },
            { key: "attendance", locator: "attendanceDetails.items", parser: function( attendance ) {
                    return Y.DataSchema.JSON.apply( {
                        resultFields: [
                            { key: "actualAttendanceId", locator: '_attributes.actualAttendanceId' },
                            { key: "attendanceDate", locator: 'attendanceDate', parser: DT.jsonParser.date },
                            { key: "timeslotCode", locator: 'timeslotCode' },
                            { key: "timeslotName", locator: 'timeslotCode', parser: function( timeslotCode ) {
                                var timeslotName;
                                Y.some( thisBlock._timeslots, function( timeslot ) {
                                    if( timeslot.timeslotCode == timeslotCode ) {
                                        timeslotName = timeslot.timeslotName;
                                        return true;
                                    }
                                });
                                return timeslotName;
                            } },
                            { key: "plannedAttendanceValueCode", locator: 'scheduled.attendanceValueCode' },
                            { key: "plannedAttendanceValueName", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var attendanceValueName;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        attendanceValueName = attendanceValue.attendanceValueName;
                                        return true;
                                    }
                                });
                                return attendanceValueName;
                            } },
                            { key: "plannedAttendanceValueType", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var attendanceValueType;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        attendanceValueType = attendanceValue.attendanceValueType;
                                        return true;
                                    }
                                });
                                return attendanceValueType;
                            } },
                            { key: "plannedAttendanceValueIsCustom", locator: 'scheduled.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var isCustom;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        isCustom = attendanceValue.isCustom;
                                        return true;
                                    }
                                });
                                return isCustom;
                            } },
                            { key: "attendanceValueCode", locator: 'actual.attendanceValueCode' },
                            { key: "attendanceValueIsException", locator: 'actual.isException', parser: DT.jsonParser.bool },
                            { key: "attendanceValueName", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var attendanceValueName;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        attendanceValueName = attendanceValue.attendanceValueName;
                                        return true;
                                    }
                                });
                                return attendanceValueName;
                            } },
                            { key: "attendanceValueType", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var attendanceValueType;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        attendanceValueType = attendanceValue.attendanceValueType;
                                        return true;
                                    }
                                });
                                return attendanceValueType;
                            } },
                            { key: "attendanceValueIsCustom", locator: 'actual.attendanceValueCode', parser: function( attendanceValueCode ) {
                                var isCustom;
                                Y.some( thisBlock._attendanceValues, function( attendanceValue ) {
                                    if( attendanceValue.attendanceValueCode == attendanceValueCode ) {
                                        isCustom = attendanceValue.isCustom;
                                        return true;
                                    }
                                });
                                return isCustom;
                            } }
                        ]
                    }, attendance ).results; 
                }
            }
        ]
    }, rtnData ).results;
    

Solution

  • This turned out to be a Firefox/Firebug problem:

    Bug 876075 - Firefox 21 slows down JSD and page load performance

    From the issue:

    Since Firefox 21 has been released, there is a lot of complaints about Firebug slowing down page load. According to the reports, it happens when the Console or the Script panel are enabled.

    This is (with high probability) related to JSD, since both Console and Scrip panel activate it.

    It just so happened that it affected this specific page I was working on, but not others.

    I disabled Firebug and all is back to normal!