-
Notifications
You must be signed in to change notification settings - Fork 50
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
node/bindnode: reduce verifyCompatibility() calls, consider caching some type info #416
Comments
This is briefly mentioned in a TODO: go-ipld-prime/node/bindnode/infer.go Line 51 in 37f875b
I'll add some context, as it doesn't seem like I wrote it down anywhere. We can globally cache any information with That kind of thing can certainly be done for I should also note that I don't think this is a problem for
It would require the prorotype to have been created by its |
👍 I was considering proposing basically this as well, for this reason. But the only excuse for needing the entire prototype is that you want to ensure the first-pass is already done. But that does seem reasonable considering the cost savings. Thanks for the input! |
Currently we run
verifyCompatibility()
on every call toPrototype()
andWrap()
(unless it's inferring a schema for you), and it's fairly expensive. Unfortunately we currently can't cache this because we have no place to cache it in.But, we could consider something like having a bindnode version of
schema.Type
that you get from aPrototype().Type()
. So, a workflow where you do an initialPrototype()
and then reuse the resultantType()
for each furtherWrap()
call. IfWrap()
finds a bindnode version ofschema.Type
it could then assume thatverifyCompatibility()
has already been performed if the Go type is the same.Further, we could take the opportunity to cache information about various properties of the Go type(s), such as field names and whether something is a pointer or not. Anything that's a little expensive to do at
Wrap()
and assemble (on thePrototype
). Even things likefieldNameFromSchema()
calls could be cached because they're showing up in profiles as a concern.The text was updated successfully, but these errors were encountered: