Skip to content
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

fix: hash chunks with djb2 #360

Merged
merged 1 commit into from
Sep 3, 2024
Merged

fix: hash chunks with djb2 #360

merged 1 commit into from
Sep 3, 2024

Conversation

katywings
Copy link
Collaborator

This replaces the hashing function with an actual hash algorithm (djb2).
The original code comes from https://github.com/sveltejs/svelte/blob/0203eb319b5d86138236158e3ae6ecf29e26864c/packages/svelte/src/utils.js#L7.

I also added a Map to avoid duplicate hashing of earlier inputs.

Comparison of the hashes

[
  { value: 'abc', hashNew: '2nhvp3', hashOld: 294 },
  { value: 'cba', hashNew: '2nhu0v', hashOld: 294 },
  {
    value: '/app/src/server/project.js',
    hashNew: '1gxub3t',
    hashOld: 2526
  },
  {
    value: '/app/src/project/server.js',
    hashNew: '1dkakbx',
    hashOld: 2526
  }
]

Performance

Benchmark wise I didn't do a lot. But the few builds I did on a large project look okay:

SSR Client Server-fns
New 1 8.93s 12.84s 9.40s
New 2 8.73s 13.38s 9.72s
New 3 8.75s 13.06s 9.43s
Median 8.73s 13.06s 9.43s
SSR Client Server-fns
Old 1 9.28s 13.80s 9.43s
Old 2 9.13s 13.23s 9.29s
Old 3 8.87s 13.88s 9.65s
Median 9.13s 13.80s 9.43s

Copy link

codesandbox bot commented Aug 30, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

changeset-bot bot commented Aug 30, 2024

🦋 Changeset detected

Latest commit: f0a1c26

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

This PR includes changesets to release 2 packages
Name Type
vinxi Patch
@vinxi/router 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

vercel bot commented Aug 30, 2024

@katywings is attempting to deploy a commit to the Nikhil Saraf's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

pkg-pr-new bot commented Aug 30, 2024

commit: f0a1c26

@vinxi/deno-doc

pnpm add https://pkg.pr.new/@vinxi/deno-doc@360

vinxi

pnpm add https://pkg.pr.new/vinxi@360

@vinxi/plugin-directives

pnpm add https://pkg.pr.new/@vinxi/plugin-directives@360

@vinxi/doc

pnpm add https://pkg.pr.new/@vinxi/doc@360

@vinxi/plugin-mdx

pnpm add https://pkg.pr.new/@vinxi/plugin-mdx@360

@vinxi/openapi

pnpm add https://pkg.pr.new/@vinxi/openapi@360

@vinxi/react

pnpm add https://pkg.pr.new/@vinxi/react@360

@vinxi/react-server

pnpm add https://pkg.pr.new/@vinxi/react-server@360

@vinxi/router

pnpm add https://pkg.pr.new/@vinxi/router@360

@vinxi/server-components

pnpm add https://pkg.pr.new/@vinxi/server-components@360

@vinxi/server-functions

pnpm add https://pkg.pr.new/@vinxi/server-functions@360

@vinxi/solid

pnpm add https://pkg.pr.new/@vinxi/solid@360

Open in Stackblitz

@katywings katywings requested a review from nksaraf August 30, 2024 16:02
Copy link

vercel bot commented Sep 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vinxi-website ❌ Failed (Inspect) Sep 3, 2024 7:04am

@nksaraf nksaraf merged commit 3925cf3 into nksaraf:main Sep 3, 2024
7 of 8 checks passed
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