Skip to content

Conversation

PupilTong
Copy link
Collaborator

@PupilTong PupilTong commented Aug 8, 2025

Summary by CodeRabbit

  • Tests
    • Renamed a performance test case for clarity.
    • Decreased the number of generated list items in the performance test from 1,000 to 100 to speed up execution.
    • Kept test logic and assertions unchanged so observed behavior and metric checks remain the same.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

Copy link

changeset-bot bot commented Aug 8, 2025

⚠️ No Changeset found

Latest commit: 54f2cde

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

📝 Walkthrough

Walkthrough

Reduced the x-list-waterfall test size: the test name changed to "x-list-waterfall-100" and the number of created list-item elements was decreased from 1000 to 100; test logic and assertions unchanged.

Changes

Cohort / File(s) Change Summary
Performance Test Case Update
packages/web-platform/web-tests/tests/performance.test.ts
Renamed the test case from x-list-waterfall-1000 to x-list-waterfall-100; test logic and assertions unchanged.
Test Fixture Adjustment
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html
Reduced the loop creating list-item elements from 1000 iterations to 100.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • gaoachao

Poem

I'm a rabbit counting hops so neat,
From thousand leaps to hundred feet.
Smaller stack, a lighter run,
Quickened pace beneath the sun.
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54f2cde and 3906013.

📒 Files selected for processing (2)
  • packages/web-platform/web-tests/tests/performance.test.ts (1 hunks)
  • packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/web-platform/web-tests/tests/performance.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1)

32-43: Remove randomness to deflake metrics: make item heights deterministic

Random heights can subtly alter layout passes and keep the test flaky. Use a deterministic height derived from the index; this preserves variability without randomness.

Apply this diff:

-      function getRandomHeight() {
-        return Math.floor(Math.random() * 151) + 150; // Generates random height between 150 and 300 (inclusive)
-      }
+      function getHeightForIndex(i) {
+        // 150..300 inclusive, deterministic by index
+        return 150 + (i % 151);
+      }
@@
-            `--item-index: ${ii}; height: ${getRandomHeight()}px;`,
+            `--item-index: ${ii}; height: ${getHeightForIndex(ii)}px;`,
🧹 Nitpick comments (1)
packages/web-platform/web-tests/tests/performance.test.ts (1)

176-176: Decouple test title from fixture name to avoid future breakage

Passing the title ties file lookup to the test name. Use an explicit fixture string like other cases in this file.

-      const cdpSession = await goto({ page, browserName, context }, title);
+      const cdpSession = await goto({ page, browserName, context }, 'x-list-waterfall-100');
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3f1e3e and b69f98f.

📒 Files selected for processing (2)
  • packages/web-platform/web-tests/tests/performance.test.ts (1 hunks)
  • packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.627Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.
Learnt from: PupilTong
PR: lynx-family/lynx-stack#1029
File: packages/web-platform/web-core/src/uiThread/createRenderAllOnUI.ts:95-99
Timestamp: 2025-07-16T05:57:29.837Z
Learning: In the lynx-stack codebase, PupilTong prefers avoiding regex for parsing in performance-critical code paths like SSR hydration, preferring simple string manipulation operations even if they're less robust, when the input format is predictable and controlled.
🔇 Additional comments (2)
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1)

36-49: LGTM on scaling down to 100 items

Reducing to 100 aligns with the new test title and should help with CI stability due to lower work per run.

packages/web-platform/web-tests/tests/performance.test.ts (1)

174-181: LGTM: Test Title Matches Fixture

Confirmed that the HTML fixture and the test title are in sync—no further changes needed.

  • Fixture exists at packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html
  • Test invocation in packages/web-platform/web-tests/tests/performance.test.ts on line 174 correctly uses 'x-list-waterfall-100'

Copy link

codspeed-hq bot commented Aug 8, 2025

CodSpeed Performance Report

Merging #1474 will not alter performance

Comparing PupilTong:p/hw/fix-x-waterfall-10000-flaky (3906013) with main (a77e659)

Summary

✅ 10 untouched benchmarks

Copy link

relativeci bot commented Aug 8, 2025

React Example

#4160 Bundle Size — 237.04KiB (0%).

3906013(current) vs a77e659 main#4159(baseline)

Bundle metrics  no changes
                 Current
#4160
     Baseline
#4159
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 0% 38.47%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 158 158
No change  Duplicate Modules 64 64
No change  Duplicate Code 45.86% 45.86%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#4160
     Baseline
#4159
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.28KiB 91.28KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-x-waterfall-1...Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link

relativeci bot commented Aug 8, 2025

Web Explorer

#4156 Bundle Size — 344.35KiB (0%).

3906013(current) vs a77e659 main#4155(baseline)

Bundle metrics  no changes
                 Current
#4156
     Baseline
#4155
No change  Initial JS 143.29KiB 143.29KiB
No change  Initial CSS 31.84KiB 31.84KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 7 7
No change  Assets 7 7
No change  Modules 211 211
No change  Duplicate Modules 17 17
No change  Duplicate Code 3.96% 3.96%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#4156
     Baseline
#4155
No change  JS 229.55KiB 229.55KiB
No change  Other 82.95KiB 82.95KiB
No change  CSS 31.84KiB 31.84KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-x-waterfall-1...Project dashboard


Generated by RelativeCIDocumentationReport issue

@PupilTong PupilTong force-pushed the p/hw/fix-x-waterfall-10000-flaky branch from b69f98f to 0d80382 Compare August 8, 2025 08:13
Copy link

codecov bot commented Aug 8, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2615 2 2613 19
View the top 1 failed test(s) by shortest run time
packages/rspeedy/plugin-qrcode/test/preview.test.ts > Preview > preview with NODE_ENV=development
Stack Traces | 4.51s run time
AssertionError: expected "spy" to be called 1 times, but got 0 times
 ❯ test/preview.test.ts:76:20
View the full list of 1 ❄️ flaky tests
packages/rspeedy/plugin-qrcode/test/index.test.ts > Plugins - Terminal > schema > custom schema object

Flake rate in main: 24.44% (Passed 34 times, Failed 11 times)

Stack Traces | 1.5s run time
Error: Matcher did not succeed in time.
 ❯ test/index.test.ts:212:53

Caused by: Caused by: Caused by: AssertionError: expected "renderUnicodeCompact" to be called 2 times, but got 1 times

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@PupilTong PupilTong force-pushed the p/hw/fix-x-waterfall-10000-flaky branch from 0d80382 to 54f2cde Compare August 11, 2025 12:35
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (2)
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (2)

32-44: Eliminate randomness to remove nondeterminism in performance metrics

Math.random() causes non-reproducible layout/style counts and can keep the test flaky even after reducing item count. Make heights deterministic from the index.

Apply:

-  function getRandomHeight() {
-    return Math.floor(Math.random() * 151) + 150; // Generates random height between 150 and 300 (inclusive)
-  }
+  function getDeterministicHeight(i) {
+    // 150..300 inclusive, stable per index
+    return 150 + (i % 151);
+  }
@@
-        for (let ii = 0; ii < 100; ii++) {
+        for (let ii = 0; ii < 100; ii++) {
           const listItem = document.createElement('list-item');
           listItem.setAttribute('item-key', ii);
           listItem.setAttribute(
             'style',
-            `--item-index: ${ii}; height: ${getRandomHeight()}px;`,
+            `--item-index: ${ii}; height: ${getDeterministicHeight(ii)}px;`,
           );

Also applies to: 37-49


36-50: Stabilize upgrade timing of custom elements and reduce reflow churn

If x-list/x-view aren’t defined when items are appended, upgrade timing can vary and affect LayoutCount/RecalcStyleCount. Also, appending one-by-one may trigger extra style/layout work.

Consider:

-      queueMicrotask(() => {
-        for (let ii = 0; ii < 100; ii++) {
-          const listItem = document.createElement('list-item');
-          listItem.setAttribute('item-key', ii);
-          listItem.setAttribute(
-            'style',
-            `--item-index: ${ii}; height: ${getDeterministicHeight(ii)}px;`,
-          );
-          listItem.setAttribute('class', 'item');
-          const xview = document.createElement('x-view');
-          xview.innerHTML = ii;
-          listItem.append(xview);
-          list.append(listItem);
-        }
-      });
+      queueMicrotask(async () => {
+        // Ensure custom elements are upgraded before populating
+        await Promise.allSettled([
+          customElements.whenDefined?.('x-list'),
+          customElements.whenDefined?.('x-view'),
+        ]);
+        const frag = document.createDocumentFragment();
+        for (let ii = 0; ii < 100; ii++) {
+          const listItem = document.createElement('list-item');
+          listItem.setAttribute('item-key', ii);
+          listItem.setAttribute(
+            'style',
+            `--item-index: ${ii}; height: ${getDeterministicHeight(ii)}px;`,
+          );
+          listItem.setAttribute('class', 'item');
+          const xview = document.createElement('x-view');
+          xview.textContent = String(ii);
+          listItem.append(xview);
+          frag.append(listItem);
+        }
+        list.append(frag);
+      });
  • Awaiting definitions removes race with the deferred library script.
  • Using a fragment batches DOM ops, reducing layout/style recomputation.
🧹 Nitpick comments (1)
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1)

46-47: Prefer textContent over innerHTML for plain text

Avoids unnecessary HTML parsing and is marginally faster/safer.

-          xview.innerHTML = ii;
+          xview.textContent = String(ii);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d80382 and 54f2cde.

📒 Files selected for processing (2)
  • packages/web-platform/web-tests/tests/performance.test.ts (1 hunks)
  • packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/web-platform/web-tests/tests/performance.test.ts
🔇 Additional comments (1)
packages/web-platform/web-tests/tests/web-elements/performance/x-list-waterfall-100.html (1)

37-37: x-list-waterfall-100 thresholds updated and naming consistent

  • In packages/web-platform/web-tests/tests/performance.test.ts (lines 174–180), the x-list-waterfall-100 test now asserts
    • LayoutCount ≤ 7
    • RecalcStyleCount ≤ 8
    which aligns with the reduced 100-item workload.
  • The HTML fixture (tests/web-elements/performance/x-list-waterfall-100.html) and the test title (x-list-waterfall-100) are in sync.

No further changes required.

@PupilTong PupilTong force-pushed the p/hw/fix-x-waterfall-10000-flaky branch from 54f2cde to 3906013 Compare August 13, 2025 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant