Skip to content

perf: graduate asset-server binary search experiment to 100% #9908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

GregBrimble
Copy link
Contributor

Graduates the asset-server binary search experiment from 50% sampling to 100% usage of the improved implementation.

The iterative binary search algorithm is currently being tested at 50% sample rate to validate its performance compared to the original recursive implementation. This PR prepares the graduation to 100% usage once the experiment proves successful.

Changes

  • Replace experimental logic in worker.ts with direct usage of improved implementation
  • Update assets-manifest.ts to use iterative binary search algorithm
  • Remove experimental files (assets-manifest.2.ts and its test file)
  • Update tests to work with new implementation signature
  • Add changeset documenting the performance improvement

Performance Impact

The improved implementation is expected to provide better performance characteristics for asset manifest lookups, which is currently being validated through the 50% experiment rollout.

@vicb This should be merged if the 50% rollout looks good and shows improvement over the original implementation.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Internal performance optimization
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: Not a Wrangler change, workers-shared package change

🤖 Generated with Claude Code

@GregBrimble GregBrimble requested review from a team as code owners July 9, 2025 16:26
Copy link

changeset-bot bot commented Jul 9, 2025

🦋 Changeset detected

Latest commit: 3291933

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/workers-shared 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

Copy link

pkg-pr-new bot commented Jul 9, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@9908

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@9908

miniflare

npm i https://pkg.pr.new/miniflare@9908

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@9908

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@9908

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@9908

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@9908

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@9908

wrangler

npm i https://pkg.pr.new/wrangler@9908

commit: 3291933

The improved iterative binary search implementation has been graduated from a 50% experiment to the default implementation. This provides better performance for asset manifest lookups by replacing the recursive binary search with an iterative approach.

Changes:
- Replace experimental logic in worker.ts with direct usage of improved implementation
- Update assets-manifest.ts to use iterative binary search algorithm
- Remove experimental files (assets-manifest.2.ts and its test file)
- Update tests to work with new implementation signature
- Add changeset documenting the performance improvement

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@GregBrimble GregBrimble force-pushed the graduate-asset-server-experiment branch from 87a8372 to a7a6ad8 Compare July 9, 2025 16:47
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM thanks for peparing the PR.

@GregBrimble I have added the PATH_HASH_OFFSET in:

- let entryOffset = HEADER_SIZE + entryIndex * ENTRY_SIZE;
+ let pathHashOffset = HEADER_SIZE + entryIndex * ENTRY_SIZE + PATH_HASH_OFFSET;

PATH_HASH_OFFSET === 0 so that's not a behavior change and it is covered by tests.

I added that because:

  • It will help if we change the offset at some point (unlikely I guess)
  • It better expresses the intent

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 10, 2025
@GregBrimble GregBrimble merged commit ab75fd8 into main Jul 10, 2025
35 of 37 checks passed
@GregBrimble GregBrimble deleted the graduate-asset-server-experiment branch July 10, 2025 15:27
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 10, 2025
@vicb vicb mentioned this pull request Jul 11, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants