Skip to content

chore(astro): Optimize stream modification - #3673

Merged
wobsoriano merged 7 commits into
mainfrom
rob/eco-19-invert-the-logic-of-decoding-the-whole-response-stream-to
Jul 9, 2024
Merged

chore(astro): Optimize stream modification#3673
wobsoriano merged 7 commits into
mainfrom
rob/eco-19-invert-the-logic-of-decoding-the-whole-response-stream-to

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Jul 8, 2024

Copy link
Copy Markdown
Member

Description

This PR tackles ECO-19 and ECO-18 and optimizes stream modification by working directly with the Uint8Array instead of decoding and re-encoding a chunk to check for string (</head>) availability. Introduces TransformStream.

A benchmark between the current implementation and the proposed is available in this gist.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Jul 8, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f5505d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/astro Patch

Not sure what this means? Click here to learn what changesets are.

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

@wobsoriano wobsoriano changed the title chore(astro): optimize stream modification with byte-level processing chore(astro): optimize stream modification Jul 8, 2024
@wobsoriano
wobsoriano marked this pull request as ready for review July 8, 2024 16:11
@wobsoriano
wobsoriano requested a review from panteliselef July 8, 2024 16:13
Comment thread .changeset/olive-foxes-own.md Outdated
"@clerk/astro": patch
---

Introduce `TransformStream` and work directly with encoded chunks when modifiying stream

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally we prefer to write more "product" oriented changesets when possilble. In this case I'd mentioned the performance boost, instead of mentioning the "how" with TransformStream

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll keep that in mind, thanks! and updated

@panteliselef panteliselef changed the title chore(astro): optimize stream modification chore(astro): Optimize stream modification Jul 9, 2024

@panteliselef panteliselef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work 💯

@wobsoriano
wobsoriano merged commit 69deca0 into main Jul 9, 2024
@wobsoriano
wobsoriano deleted the rob/eco-19-invert-the-logic-of-decoding-the-whole-response-stream-to branch July 9, 2024 12:42
wobsoriano added a commit that referenced this pull request Jul 9, 2024
Co-authored-by: panteliselef <panteliselef@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants