Skip to content

Conversation

@mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented Nov 25, 2025

Describe your changes

Attempt to improve initial load time by reducing dependencies included in entry bundle.

Changes made:

  • Remove apache-arrow from entry bundle ${\color{red}Delayed}$ - add_rows deprecation

    • Refactor ElementNode to move Quiver instantiation logic into components
  • Lazy load FormSubmitContent & ComponentInstance


Bundle Analysis:

Before: 2.38 MB & After: 2.36 MB

@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 25, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Collaborator Author

mayagbarnes commented Nov 25, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13115/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13115.streamlit.app (☁️ Deploy here if not accessible)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

📉 Significant wheel size change detected

The wheel file size has decreased by 0.26% (threshold: 0.25%)

  • Current PR: 8758.53 KB
  • Latest develop: 8781.64 KB

Please verify that this change is expected.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

📉 Significant bundle size change detected

Metric This Branch develop Change (%)
Total (gzip) 8.16 MiB 8.16 MiB -0.01%
Entry (gzip) 749.54 KiB 756.8 KiB -0.96%

Please verify that this change is expected.

📊 View detailed bundle comparison

@mayagbarnes mayagbarnes changed the title Reorganize and lazy load couple other components Reduce entry bundle size - Part 4 Nov 25, 2025
@mayagbarnes mayagbarnes added change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR labels Nov 25, 2025 — with Graphite App
@sfc-gh-mbarnes sfc-gh-mbarnes force-pushed the reduce-bundle-4 branch 2 times, most recently from 0457491 to 5183381 Compare November 25, 2025 05:59
@mayagbarnes mayagbarnes requested a review from Copilot November 25, 2025 07:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR successfully reduces the entry bundle size from 2.38 MB to 2.15 MB by removing apache-arrow from the entry bundle. It achieves this by refactoring ElementNode to defer Quiver instantiation to component-level, storing raw Arrow proto data instead.

Key Changes

  • Refactored ElementNode to store raw Arrow proto data and accumulate addedRowsList instead of instantiating Quiver eagerly
  • Moved Quiver instantiation logic from ElementNode to components (DataFrame, ArrowTable, ArrowVegaLiteChart)
  • Added new utility functions in dataframeUtils.ts for consistent Quiver creation and merging
  • Lazy-loaded ComponentInstance and FormSubmitContent for additional bundle size reduction
  • Updated error messages to remove stack traces for cleaner UI display

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/lib/src/render-tree/ElementNode.ts Refactored to store raw Arrow proto data and addedRowsList instead of instantiating Quiver; removed merge helper functions
frontend/lib/src/render-tree/ElementNode.test.ts Updated tests to verify raw data storage instead of Quiver instantiation
frontend/lib/src/dataframes/dataframeUtils.ts New utility file with functions for Quiver creation and merging
frontend/lib/src/dataframes/dataframeUtils.test.ts Comprehensive tests for new utility functions
frontend/lib/src/dataframes/arrowConcatUtils.ts Refactored error messages to single-line format without stack traces
frontend/lib/src/dataframes/__snapshots__/Quiver.test.ts.snap Updated snapshots reflecting new error message format
frontend/lib/src/dataframes/Quiver.ts Added createError method for user-facing errors without stack traces
frontend/lib/src/components/widgets/DataFrame/ReadOnlyGrid.tsx Updated to accept IArrow | Quiver and extract data bytes for DataFrame
frontend/lib/src/components/widgets/DataFrame/ReadOnlyGrid.test.tsx Updated tests to pass IArrow instead of Quiver instances
frontend/lib/src/components/widgets/DataFrame/DataFrame.tsx Added useMemo to instantiate Quiver from proto and merge addedRowsList
frontend/lib/src/components/widgets/DataFrame/DataFrame.test.tsx Updated to pass raw data instead of Quiver instances in props
frontend/lib/src/components/elements/ArrowVegaLiteChart/arrowUtils.ts Added buildVegaLiteChartElement function to construct VegaLiteChartElement from proto and added rows
frontend/lib/src/components/elements/ArrowVegaLiteChart/arrowUtils.test.ts Added comprehensive tests for buildVegaLiteChartElement
frontend/lib/src/components/elements/ArrowVegaLiteChart/ArrowVegaLiteChart.tsx Updated to use buildVegaLiteChartElement and pass raw data to ReadOnlyGrid
frontend/lib/src/components/elements/ArrowVegaLiteChart/ArrowVegaLiteChart.test.tsx Updated to pass proto instead of VegaLiteChartElement
frontend/lib/src/components/elements/ArrowTable/ArrowTable.tsx Added useMemo to instantiate Quiver from proto and merge addedRowsList
frontend/lib/src/components/elements/ArrowTable/ArrowTable.test.tsx Updated to pass raw data in proto instead of separate Quiver instances
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx Updated to extract raw data from ElementNode and lazy-load ComponentInstance and FormSubmitContent
e2e_playwright/st_add_rows_test.py Updated test selector from stAlert to more specific stAlertContentError
Comments suppressed due to low confidence (1)

frontend/lib/src/dataframes/Quiver.ts:320

  • This string appears to be missing a space after 'of'.
          " If you do not need the Styler's styles, try passing the .data attribute of" +

@mayagbarnes mayagbarnes changed the base branch from reduce-bundle-3 to graphite-base/13115 November 25, 2025 19:46
@mayagbarnes mayagbarnes changed the base branch from graphite-base/13115 to reduce-bundle-3 November 25, 2025 20:20
@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0100%

  • Current PR: 87.5800% (51147 lines, 6352 missed)
  • Latest develop: 87.5900% (51141 lines, 6346 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

Base automatically changed from reduce-bundle-3 to develop November 25, 2025 21:21
@mayagbarnes mayagbarnes marked this pull request as ready for review November 25, 2025 22:06
@@ -81,8 +80,6 @@ import { Skeleton } from "~lib/components/elements/Skeleton"
import TextElement from "~lib/components/elements/TextElement"
import ErrorBoundary from "~lib/components/shared/ErrorBoundary"
import Heading from "~lib/components/shared/StreamlitMarkdown/Heading"
import { ComponentInstance } from "~lib/components/widgets/CustomComponent"
Copy link
Collaborator Author

@mayagbarnes mayagbarnes Nov 26, 2025

Choose a reason for hiding this comment

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

In addition to the couple added lazy loads, this was just reorganizing components back into alphabetical order under each elements/widgets comment

@@ -299,23 +299,28 @@ export class Quiver {
return this._data.getChildAt(columnIndex)?.get(rowIndex)
}

/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These errors are now rendered through the ErrorBoundary in ElementNodeRenderer which does not support markdown in the message.

@lukasmasuch
Copy link
Collaborator

We just deprecated the add_rows feature since it has almost no usage but a lot of overhead: #13063 #13080 If we don't get a strong feedback to keep it, we will probably remove this soon. Based on that, I'm not sure if we should touch this feature right now but I will take a closer look at the changes a bit later.

Maybe if possible we can prioritize the #13128 and Lazy load FormSubmitContent & ComponentInstance aspect since this looks good to go for 1.52 release

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@mayagbarnes mayagbarnes merged commit b6a08d9 into develop Nov 28, 2025
43 checks passed
@mayagbarnes mayagbarnes deleted the reduce-bundle-4 branch November 28, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants