OData / OData/AspNetCoreOData

Perf: Creating OData properties is expensive

Open
#1,109 3 comments 1 reaction 1 assignee View on GitHub

@ElizabethOkerio is already working on this.

Since Nov 28, 2023.

P2 performance
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

During serialization, a relatively high amount of CPU is used to create ODataProperty instances that are used to populate ODataResource objects. This is performed in the ODataSerializerPropertyHelper.CreateProperty method.

The most of the cost come's from the property's EDM serializer's call to CreateODataValue.

image

The ODataPrimitiveSerializer.CreateODataValue:

  • makes expensive calls to ODL's EdmTypeSemantics, see: https://github.com/OData/odata.net/issues/2807
  • ODataPrimitiveSerializer.ConverUnsupportedPrimitives seems to be expensive due to its reliance on Type.GetTypeCode(). We should assess whether there are more efficient ways to handle CLR primitive types that are not part of ODL's core primitive types.

The ODataEnumSerializer.CreateODataValue:

  • retrieves the ClrEnumMemberAnnotation from the the IEdmModel annotations cache. This model's annotation cache is constant performance hog that does not seem easy to optimize.
  • does an expensive dictionary lookup to retrieve the EDM enum value corresponding to the CLR enum value
  • makes an expensive call to Enum.ToString()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.