-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
perf: replace flatted with devalue for serialization
#9549
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
Draft
hi-ogawa
wants to merge
31
commits into
vitest-dev:main
Choose a base branch
from
hi-ogawa:refactor/consolidate-flatted-serialization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
perf: replace flatted with devalue for serialization
#9549
hi-ogawa
wants to merge
31
commits into
vitest-dev:main
from
hi-ogawa:refactor/consolidate-flatted-serialization
+182
−152
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add new serialization module to @vitest/utils with parse, stringify, stringifyRaw, stringifyReplace, and toJSON exports - Migrate all flatted imports to use @vitest/utils/serialization - Remove duplicate stringifyReplace implementations - Consistent Error serialization across all usages Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Add examples/demo-8710/ for benchmarking blob reporter output size and merge-reports execution time with configurable test counts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vitest/utils/serializationflatted with devalue for serialization
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I compared three serialization library.
Here is a benchmark of large blob report serialization (~500 test files, 50000 tests). See https://github.com/hi-ogawa/reproductions/tree/main/vitest-9549-serializer for details.
(Note that
@ungap/structured-clone's data isn't generated through Vitest, but it simply tests equivalent data by converting from flatted result.)and blob file size comparison:
It appears that
flatted's simple implementation has some edge and it's not like modern-ish alternative wins absolutely. For Vitest use case, there's probably no crystal clear reason to replaceflattedat the moment, other than perhaps building our own serializer to pick up the good parts of all. If I would choose one based on my test, I think I'd choosedevalueas it's most battle tested and most flexible, but not sure what others think.Here are some thoughts on options (and non options)
devalue
parseundefinedkey value is included. otherwise smaller thanflatted. it's should be possible to omit these from custom replacer, but haven't tried.stringify@ungap/structured-clone
flattedstructureClone(though Vitest doesn't use them)flattedreplacer/reviverlikeflatted(Vitest needs minor customization onErrorinstance)other options (e.g. seroval, turbo-stream)
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.