Skip to content

[$250] [HOLD for payment 2024-06-28] [HOLD for payment 2024-06-24] [LOW] [Performance] Improve the performance of getOrderedReportIDs #43488

Description

@mountiny

Coming from here

Problem

Constantly copying all reports in the getOrderedReportIDs function is resource-intensive. We're doing this just to add a single property, and we are using only 2 copied properties. This process significantly increases the function's runtime.

report = {
    ...report,
    displayName: ReportUtils.getReportName(report),
};

Solution

Avoid copying the entire report object. Instead, create a minimized report version that only includes the necessary properties. This approach is safe as these data are used solely for sorting.

type MiniReport = {
    reportID?: string;
    displayName: string;
    lastVisibleActionCreated?: string;
};
// ...

const miniReport: MiniReport = {
    reportID: report?.reportID,
    displayName: ReportUtils.getReportName(report),
    lastVisibleActionCreated: report?.lastVisibleActionCreated,
};

On my heavy account, I've tested it, and here are the results:

  • getOrderedReportIDs function call time: 36% improvement in performance, reduced from 185ms (SD 3ms) → 118ms (SD 8ms), n = 10, measured in the code,
  • ReportIDsContextProvider render time: 28% improvement in performance, reduced from 233ms (SD 4ms) → 168ms (SD 2ms), n = 3, measured using a profiler,

A POC with performance measurements is available here. Please let me know if you have any questions.

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01facc6fcf70a639b9
  • Upwork Job ID: 1805325257306582163
  • Last Price Increase: 2024-06-24
Issue OwnerCurrent Issue Owner: @joekaufmanexpensify

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions