Skip to content

Conversation

@filzrev
Copy link
Contributor

@filzrev filzrev commented Feb 18, 2025

This PR intended to fix #9973.

On current implementation.
APIPage deserialization internally throw a lot of exception internally.
And when the debugger is attached, this will cause performance slow down significantly.

So I've added IsDeserializableType method that check following context.

  1. Utf8JsonReader information
    1.1. Current JsonTokenType
    1.2. Prefetched first PropertyName of JSON object. (e.g. h1/api1/facts)
  2. Expected type that to be deserialized by JsonSerializer.
  3. Expected type that to be converted by JsonConverter.

And skip deserialization if current context is not valid three pairs combinations.

Additionally, when unknown combination found. (It will be happens when APIPage's schema is updated)
IsDeserializableType method returns true.
And fallback to default behavior (Try to deserialize and catch exception)
So it works without problems for future updates.

@filzrev filzrev force-pushed the perf-optimize-deserialize-apipage branch from 6f5b133 to edede3a Compare February 18, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Makes the pull request appear in "Performance" section of the next release note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support faster deserialization of OneOf based types

2 participants