microsoft / microsoft/OpenAPI.NET.OData

EntityModel.ConvertToOpenApi method memory usage

未关闭
#389 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
240
派生
70
平均合并
7 小时 59 分钟
30 天内合并 PR
13

描述

When using IEdmModel.ConvertToOpenApi - some EDMX documents appear to trigger massive memory usage on some occasions it never seems to finish, I've left it for upwards of 30 minutes. I am trying to generate documentation for Microsoft Dynamics Business Central API's.

Assemblies affected

This is a C# WPF .NET7.0 app

  • Microsoft.OpenApi V1.6.4
  • Microsoft.OpenApi.OData V1.4.0
  • Microsoft.OpenApi.Readers V1.6.4

Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi()

Steps to reproduce

the below code in conjunction with the example EDMX examples replicates the issue

var EdmData = System.IO.File.ReadAllText(ExampleEdmxFilePath);
IEdmModel model = CsdlReader.Parse(XElement.Parse(EdmData).CreateReader());
var document = EntityModel.ConvertToOpenApi();

Expected result

The OpenApiDocument is created quickly and with reasonable memory usage

Actual result

The OpenApiDocument is not created/created very slowly and uses massive amount of memory

Additional detail

From the attached zip file

  • EDMX 1 - this is a collection of ~15 custom API's - the OpenApiDocument takes around 5 minutes to be created, if I export this to a json OpenApiv3 document the resulting file is 3.5Gb and it generates ~22,000 paths, it's uses ~9Gb of memory according to Visual Studio resource profiler. If I import the OpenApiV3 Json document into Swagger it is not recognised so I suspect the 3.5Gb is just hitting some form of limit.
  • EDMX 2 - a separate set of 20 or so custom api's, appears to work correctly, the OpenApiDocument takes a few seconds to generate and uses very little memory
  • EDMX 3 - the collection of all standard Microsoft Dynamics Business Central API V2 API's, I've never got this to finish, I've left it for over 30 minutes and it's used up to 20Gb of memory.

EDMX examples.zip

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi() 开始,使用附带的 EDMX 示例和 issue 中的 C# 解析序列复现该行为。在对内存使用量和生成时间进行性能分析的同时,将较小的可正常工作的模型与 EDMX 1 和 EDMX 3 进行比较。当有问题的 EDMX 文档能够生成 OpenApiDocument,且不会过度使用内存或出现明显挂起时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, openapi
领域
api, backend-api-design, performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。