Skip to content

[LiveComponent] Split a download response without copying it - #4272

Merged
smnandre merged 1 commit into
symfony:3.xfrom
Kocal:perf/live-component-download-split-views
Nov 24, 2026
Merged

smnandre merged 1 commit into
symfony:3.xfrom
Kocal:perf/live-component-download-split-views

Conversation

@Kocal

@Kocal Kocal commented Nov 14, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? no
Deprecations? no
Documentation? no
Issues
License MIT

For a response with a file download, BackendResponse split the body with two ArrayBuffer.slice() calls, which copy the HTML part and the file part, before the TextDecoder and the Blob copy them again.

Now both parts are Uint8Array views on the same buffer. An invalid or out-of-range X-Live-Html-Length gives the same split as slice() did (new tests).

With a 20 MB file in Chromium: 19.8 ms -> 12.0 ms, and 20 MB less memory allocated during the split.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
LiveComponent
live_controller.js 93.97 kB / 21.36 kB 94.19 kB0% / 21.45 kB0%

@Kocal
Kocal force-pushed the perf/live-component-download-split-views branch 3 times, most recently from a784e30 to d7657da Compare November 16, 2026 22:28
| Q              | A
| -------------- | ---
| Bug fix?       | no
| New feature?   | no
| Deprecations?  | no
| Documentation? | no
| Issues         |
| License        | MIT

For a response with a file download, `BackendResponse` split the body with two `ArrayBuffer.slice()` calls, which copy the HTML part and the file part, before the `TextDecoder` and the `Blob` copy them again.

Now both parts are `Uint8Array` views on the same buffer. An invalid or out-of-range `X-Live-Html-Length` gives the same split as `slice()` did (new tests).

With a 20 MB file in Chromium: 19.8 ms -> 12.0 ms, and 20 MB less memory allocated during the split.
@Kocal
Kocal force-pushed the perf/live-component-download-split-views branch from d7657da to b28a180 Compare November 16, 2026 22:42

@smnandre smnandre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great!

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Nov 24, 2026
@smnandre

Copy link
Copy Markdown
Member

Thanks @Kocal.

@smnandre
smnandre merged commit b9189d9 into symfony:3.x Nov 24, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LiveComponent Performance Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants