Share pointer children#1284
Draft
frenchy64 wants to merge 56 commits into
Draft
Conversation
This was referenced Jun 28, 2026
Collaborator
Author
|
After some reflection, I think the essence of this change is an integrated mechanism to detect recursive schemas. We endlessly work around this missing feature in order to detect cycles in each operation. If malli intrinsically handled recursive schemas to always be equal, then these cycle checks become simply equality checks. This needs to be a user-level expectation, with documentation explaining the scenarios where the knot is tied at the schema level. |
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
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.
Schemas like
[:schema {:registry {::FOO :bar}} ::FOO]now create:baronce (before, twice). This is regardless of how many times::FOOis mentioned in the registry or bodyFor example it also holds for
which would previously create 3 copies of
:barvia-property-registry, then 3 additional copies via[:tuple ::BAZ ::BAZ ::BAZ]for a total of 6 copies (now 1).The situation is more subtle for nested registries, see the tests.
This tackles exponential duplication of schemas. Previously,
(m/schema [:schema {:registry exponential-schema}} ::creates-4194304-validators])would create at least 4,194,304 copies of::counting, now only 1. I'm not sure of the exact number because of OOM errors, but it could be closer to 20 million.Note:
(m/validator [:schema {:registry exponential-schema}} ::creates-4194304-validators])still callsm/-validator4,194,304 times, as noted in theTODOat the bottom ofmalli.core-testin this PR. This can be tackled separately.Metabase works around this a similar issue here by creating their own
:refimplementation. We don't handle:refhere yet.