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

Cache JSON schema generated in CompleteAsync<T> #5482

Closed
stephentoub opened this issue Oct 8, 2024 · 4 comments · Fixed by #5513
Closed

Cache JSON schema generated in CompleteAsync<T> #5482

stephentoub opened this issue Oct 8, 2024 · 4 comments · Fixed by #5513

Comments

@stephentoub
Copy link
Member

Currently each call to CompleteAsync<T> generates a schema:

var schemaNode = (JsonObject)serializerOptions.GetJsonSchemaAsNode(typeof(T), new()

This should be cached, e.g. via a ConditionalWeakTable associated with the corresponding JsonSerializer.

@eiriktsarpalis
Copy link
Member

To be clear, this should be reusing the same caching infrastructure used by the existing InferSchema helpers.

@stephentoub
Copy link
Member Author

To be clear, this should be reusing the same caching infrastructure used by the existing InferSchema helpers.

Only tangentially-related, you thought we should consider exposing some of that publicly, yes? If so, could you open an issue to track? Thanks.

@eiriktsarpalis
Copy link
Member

Yes, given the current shape of function calling exposing these helpers to other implementers is almost mandatory.

@stephentoub
Copy link
Member Author

Being addressed in #5513

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants