-
-
Notifications
You must be signed in to change notification settings - Fork 112
refactor: Use index vec to store the schema nodes #749
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #749 +/- ##
==========================================
+ Coverage 85.71% 86.14% +0.43%
==========================================
Files 95 100 +5
Lines 15531 16362 +831
==========================================
+ Hits 13312 14095 +783
- Misses 2219 2267 +48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #749 will not alter performanceComparing Summary
Benchmarks breakdown
|
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
I was looking a bit more into the memory usage of this library, and I have an additional sidenote that I'll leave here. jsonschema/crates/jsonschema/src/keywords/ref_.rs Lines 124 to 142 in 958b430
I think that the current recursive-validators manage to build a cyclic family of |
Thank you for taking a deep look into this! The presence of registry, ctx, etc, is surely an awful hack. In this PR, the static references are resolved at the compilation step, so there is no need to keep those structures. I am not sure about Right now, static refs work in the new compiler, so adding As a side note, another factor contributing to memory usage could be the presence of many separate allocations (every node is boxed). I believe that, depending on the used allocator, memory fragmentation may also impact the final result. Gradually, I want to pack things more (e.g. intern |
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
Signed-off-by: Dmitry Dygalo <[email protected]>
This is yet another attempt to improve the schema tree layout without going fully into building a compiler & interpreter, as noted in #641 (which will require way more effort).
The core goal is to prevent excessive memory consumption by recursive references, which are evaluated lazily and keep expanding on each deeper recursion cycle (#675).
Solving the above issue should also remove the need to store
Registry
insideValidator
, and, in principle, it should be possible to passRegistry
by reference. It will unblock a better API forjsonschema
where the user won't need to pass theRegistry
by value (likely cloning it).Inspired by changes I made in the
css-inline
crate a few years ago.