Page MenuHomePhabricator

[Spike 4hours] Performance Impact Assessment for Night Mode Style Correction
Closed, ResolvedPublic1 Estimated Story Points

Description

We want to explore using a CSS-only solution for fixing user generated content using a CSS attribute contains query, but we have reservations around performance.

Conduct a performance impact assessment of applying a global CSS rule [style*=background] { color: #333; } to correct text color in night mode for all elements with a specified background style. This task involves setting up test scenarios to measure page rendering times, resource utilization, and overall user experience before and after applying the rule. Deliverables include a detailed report on findings, with analysis on whether the solution meets performance standards for deployment on Wikimedia projects.

Timebox

half a day

Outcome

An assessment of whether this is viable or not.

Event Timeline

Jdlrobson renamed this task from Performance Impact Assessment for Night Mode Style Correction to [Spike] Performance Impact Assessment for Night Mode Style Correction.Feb 22 2024, 5:50 PM
Jdlrobson triaged this task as High priority.
Jdlrobson set the point value for this task to 1.
ovasileva renamed this task from [Spike] Performance Impact Assessment for Night Mode Style Correction to [Spike 4hours] Performance Impact Assessment for Night Mode Style Correction.Feb 22 2024, 6:51 PM

Talked through this with Mo

I have added

[style*="background"] {
	color: @color-inverted;
}

Locally there is no performance impact, even with 6x throttling, and seems that is also supported by https://github.com/amcss/am-benchmarks and https://stackoverflow.com/questions/22284219/css-performance-between-class-and-attribute-selectors outcomes, Should we proceed with a synthetic speed test?

Change 1006872 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/skins/MinervaNeue@master] [POC] Attribute selector contrast issue fix

https://gerrit.wikimedia.org/r/1006872

Change 1007352 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[operations/mediawiki-config@master] Performance Impact Assessment for Night Mode Style Correction

https://gerrit.wikimedia.org/r/1007352

We discussed in SHDT:
@Mabualruz to:

The local results:

Once the patch has a +1 it needs to be scheduled on the next deploy window. I suggest 1 more local result attached from a different machine and check on the online speed test files on sign-off I will move this to review

Looking closely I think we should be using an article where the selector would apply to lots of elements. I have suggested using the URL https://en.m.wikipedia.org/wiki/2023_Formula_One_World_Championship?minervanightmode=1 for the tests.

Jdlrobson lowered the priority of this task from High to Medium.Feb 29 2024, 5:57 PM

Change 1007352 merged by jenkins-bot:

[operations/mediawiki-config@master] Performance Impact Assessment for Night Mode Style Correction

https://gerrit.wikimedia.org/r/1007352

Mentioned in SAL (#wikimedia-operations) [2024-02-29T21:04:07Z] <jdrewniak@deploy2002> Started scap: Backport for [[gerrit:1007352|Performance Impact Assessment for Night Mode Style Correction (T358240)]]

Mentioned in SAL (#wikimedia-operations) [2024-02-29T21:05:37Z] <jdrewniak@deploy2002> mabualruz and jdrewniak: Backport for [[gerrit:1007352|Performance Impact Assessment for Night Mode Style Correction (T358240)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-02-29T21:13:36Z] <jdrewniak@deploy2002> Finished scap: Backport for [[gerrit:1007352|Performance Impact Assessment for Night Mode Style Correction (T358240)]] (duration: 09m 28s)

@Mabualruz could you please also do a brief write up (with screenshots) describing what you see here and why we can be confident that this is not a performance issue. I don't think it's sufficient to just add two JSONs to this task and expect people to download them and review them and determine that themselves.

Live Night Mode With Selector:

LiveNightModeWithSelector.png (1×3 px, 577 KB)

Live Night Mode No Selector:

LiveNightModeNoSelector.png (1×3 px, 583 KB)

Short Answer

Upon reviewing the performance data collected from both scenarios—with and without the night mode style selector—we observed that the scenario with the selector had fewer total events (49,826 events) compared to the scenario without the selector (51,906 events). However, the total duration of events was slightly longer with the selector (7,798.584 ms) compared to without (6,993.239 ms). This suggests that while the implementation of the night mode style correction slightly increases the processing time, it also reduces the total number of events that need to be processed. This efficiency in reducing event counts may offset the marginal increase in processing duration, leading to our conclusion that the performance impact is minimal and within acceptable parameters for user experience. We remain open to further discussion and analysis to ensure a comprehensive understanding of these findings.

Data analysis

The data from both files (liveNightModeWithSelector.json.gz and liveNightModeNoSelector.json.gz) is structured into two main keys: traceEvents and metadata. This structure suggests that the files contain performance tracing information and associated metadata.

Examine both files:

  1. Metadata Comparison: Quick review of the metadata to understand the context of each test scenario.
  2. Trace Events Analysis: Analyse the traceEvents for both scenarios to identify any significant differences in performance metrics, such as execution times, resource loading, or any other indicators of performance impact.

The metadata comparison between the two files reveals that both tests were conducted under similar conditions, focusing on the page load use case. Here are some key observations:

  • Source: Both sets of data were collected using DevTools, ensuring consistency in the data collection method.
  • Track Configuration: The configuration for tracked events, such as LayoutShiftTrack, NetworkTrack, and RendererTrack, was the same across both tests. This indicates that the comparison will be fair and focused on the same performance aspects.
  • Use Case: The use case for both tests was "Page load," which is crucial for understanding the impact of the night mode style correction during initial page loading.
  • Network and CPU Throttling: Both tests were conducted without network throttling and with the same level of CPU throttling (6). This ensures that any observed performance differences are not influenced by external throttling factors.

Given the consistency in testing conditions, any differences in the traceEvents data will provide a clear insight into the performance impact of implementing the night mode style correction. Let's now analyse the traceEvents data to identify any performance differences. ​​

The analysis of the traceEvents data from both test scenarios reveals the following:

  • Total Events:
    • With Selector: 49,826 events
    • No Selector: 51,906 events
  • Total Duration (in milliseconds):
    • With Selector: 7,798.584 ms
    • No Selector: 6,993.239 ms

This data indicates that the scenario with the selector had fewer total events compared to the scenario without the selector. However, the total duration for processing these events was longer in the scenario with the selector. This could suggest that while there are fewer events to process when the selector is used, the complexity or nature of these events could result in a slightly longer processing time.

Jdlrobson added a subscriber: SToyofuku-WMF.

Thanks for the write up Mo. I've linked this to the task in the next sprint where we'll implement this (T358797) and suggested this eventually gets incorporated into a team ADR.

It makes sense to me that this rule could reduce time to paint the page, while also applying to more elements, since the rule basically disables painting for certain elements, but I'd love another closer look at this before sign off.

@SToyofuku-WMF when you are back I would appreciate if you could look through this and ask any questions that might come to mind and resolve the ticket when you are happy we have all the information needed here.

This looks great and makes sense to me as well - thank you so much @Mabualruz for the detailed write-up this was very easy to follow! Going to mark as resolved and remember this task for the next time we have to do a similar perf analysis