Performance: Only build matrix for flowchart when needed

Created on 12 May 2020, about 4 years ago
Updated 2 February 2024, 5 months ago

Problem/Motivation

While profiling a site that is very lightly using this module, I noticed Drupal\business_rules\Util\Flowchart\Matrix::__construct using a decent chunk of memory, over 4MB.

β†’

The page I was profiling was not displaying any flowcharts. Based on my quick look at the architecture, the Drupal\business_rules\Util\BusinessRulesUtil class might end up being loaded on nearly every page of a Drupal site, and that loads the flowchart util class, which in turns builds a matrix.

Proposed resolution

Only initialize the matrix when a flowchart is being built.

Remaining tasks

  • Patch
  • Review

User interface changes

n/a

API changes

I wouldn't consider this an API change but I am proposing to change the constructor of Drupal\business_rules\Util\Flowchart\Flowchart so maintainers should keep that in mind.

Data model changes

n/a

Release notes snippet

Probably doesn't need to be included in release notes.

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Cottser

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024