Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight performance improvement when rendering data table visualisations #15044

Merged
merged 2 commits into from Nov 4, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Oct 23, 2019

refs #15037

Currently it is checking if a data table is empty when means twig will call the toString method of our dataTables

image

which means for regular data tables it will use the HTML renderer just to check if the table is empty, for Maps it will use the console renderer. They always return a non empty string though meaning the check is kind of useless and only consumes CPU.

@tsteur tsteur added c: Performance For when we could improve the performance / speed of Matomo. Needs Review PRs that need a code review labels Oct 23, 2019
@tsteur tsteur added this to the 3.13.0 milestone Oct 23, 2019
@@ -2,7 +2,7 @@
{% include visualizationTemplate %}
{%- else -%}

{% set isDataTableEmpty = (dataTable is empty or dataTableHasNoData|default(false)) %}
{% set isDataTableEmpty = (dataTable is not defined or dataTableHasNoData|default(false)) %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might it be possible that dataTable is null in some cases? If so it might be better to maybe also check for dataTable is null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@diosmosis diosmosis merged commit b048ae1 into 3.x-dev Nov 4, 2019
@diosmosis diosmosis deleted the datatableperftweak branch November 4, 2019 00:29
@diosmosis
Copy link
Member

I just merged this, but it seems like it would be easy for this to happen again. I wonder if we should just remove the __toString() method from DataTable (in matomo 4, I suppose).

@tsteur
Copy link
Member Author

tsteur commented Nov 4, 2019

@diosmosis just not sure why it was added in the first place? If it's not needed for something else then could just change it to return a simple string or so... it should otherwise not make performance much slower if it happens again. If we know the tostring is not needed though then be good.

@diosmosis
Copy link
Member

It would probably be difficult to see everywhere a datatable could be converted into a string... I guess we could just change it to return 'ROWS: $rowCount' or '' if no rows and see if the tests pass.

diosmosis pushed a commit that referenced this pull request Nov 6, 2019
…ns (#15044)

* Slight performance improvement when rendering data table visualisations

refs #15037

* apply review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants