Skip to content

[Due for payment 2025-02-25] [$250] Improve performance of the function responsible for displaying RBR in LHN and bottom tabs #56730

Description

@mountiny

Coming from here

Background

If a report has a violation (e.g., a failed receipt scan), we mark it with RBR in the LHN. To indicate that action is required, RBR also appears in the Workspace Switcher next to the policy containing the report and in the bottom tabs alongside the Inbox item.

Problem

The logic for determining whether to display RBR in the LHN and Inbox tab is inefficient, consuming excessive CPU resources and slowing down the rendering process. The function getOrderedReportIds, previously identified as slow for accounts with a large number of reports, is significantly impacted. Performance results for an account with 15k reports on web:

  • getOrderedReportIDs takes 1.35s, delaying LHN rendering.
  • getBrickRoadForPolicy takes 392ms, affecting the Inbox tab in the bottom navigation.

The issue is caused by shouldDisplayViolationsRBRInLHN , which is being inefficient when handling large amounts of reports and policies - it took 1.63s in total.

Solution

Refactor shouldDisplayViolationsRBRInLHN to eliminate redundant computations. Instead of iterating through all reports within the function on every call, build a precomputed map of reports by policyID. This enables quick lookups and significantly reduces processing time. Performance gains after optimization:

  • getOrderedReportIDs: 435ms (-900ms)
  • getBrickRoadForPolicy: 3ms (-389ms)
  • shouldDisplayViolationsRBRInLHN: 10ms (-1.63s)
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021889571854486041914
  • Upwork Job ID: 1889571854486041914
  • Last Price Increase: 2025-02-12
Issue OwnerCurrent Issue Owner: @TMisiukiewicz

Metadata

Metadata

Labels

AutoAssignerNewDotQualityUsed to assign quality issues to engineersAwaiting 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