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

[API Review] Memory performance improvements #1971

Open
RachitMalik12 opened this issue Nov 26, 2024 · 0 comments
Open

[API Review] Memory performance improvements #1971

RachitMalik12 opened this issue Nov 26, 2024 · 0 comments
Labels
priority:p0 Blocking issue/ loss of critical functions. An ICM may be filed to communicate urgency. SLA<=48hrs
Milestone

Comments

@RachitMalik12
Copy link

Currently we instantiate new objects every time for the following properties, this can have a large memory impact for large OpenAPI descriptions. For eg: For the Graph OpenAPI this will create 142k schemas, for a total of 1.1 million objects that might be unused. So we have an opportunity for some memory perf. improvements by lazily instantiating these.

 public virtual IDictionary<string, OpenApiSchema> PatternProperties { get; set; } = new Dictionary<string, OpenApiSchema>();
        public virtual IList<JsonNode> Enum { get; set; } = new List<JsonNode>();
        public virtual IList<OpenApiSchema> AllOf { get; set; } = new List<OpenApiSchema>();
        public virtual IList<OpenApiSchema> OneOf { get; set; } = new List<OpenApiSchema>();
        public virtual IList<OpenApiSchema> AnyOf { get; set; } = new List<OpenApiSchema>();
        public virtual ISet<string> Required { get; set; } = new HashSet<string>();
        public virtual IDictionary<string, OpenApiSchema> Properties { get; set; } = new Dictionary<string, OpenApiSchema>();
        public virtual IDictionary<string, IOpenApiExtension> Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>();

A couple of different ideas were identified:

  1. Lazy Instantiation: Explore using the init pattern and lazy get instantiation to reduce unnecessary object allocations in the OpenAPISchema
  2. Structs vs. Classes: Evaluate the possibility of redefining OpenAPISchema and other types as structs instead of classes to improve performance.
  3. IDictionary properties should have a default value and no setter.
@RachitMalik12 RachitMalik12 added the priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days label Nov 26, 2024
@RachitMalik12 RachitMalik12 added this to the NET:2.0 milestone Nov 26, 2024
@RachitMalik12 RachitMalik12 added priority:p0 Blocking issue/ loss of critical functions. An ICM may be filed to communicate urgency. SLA<=48hrs and removed priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p0 Blocking issue/ loss of critical functions. An ICM may be filed to communicate urgency. SLA<=48hrs
Projects
None yet
Development

No branches or pull requests

2 participants