httpgenerator icon indicating copy to clipboard operation
httpgenerator copied to clipboard

Excesive RAM use.

Open blogcraft opened this issue 1 year ago • 6 comments

Describe the bug While running httpgenerator using a URL Swagger it runs long with a 100% use of RAM. I have 32 GB of ram and under idle have 50% idle. While running the generator, it used all the rest of the aviable ram and kept working for like 15 minutes.

image

image

image

Support Key: [jxag/3e]

OpenAPI Specifications Sorry, but it is not public.

blogcraft avatar May 29 '24 19:05 blogcraft

After 30+ minutes running I had to stop it.

blogcraft avatar May 29 '24 19:05 blogcraft

@blogcraft thanks for taking the time to report this. I have honestly no idea what's going on but the tool doesn't really do anything fancy. It's pretty much just an advanced text parser that generates more text, asynchronously writes to files on disk in parallel, and once done, the process is killed

I'll play around with a couple of large OpenAPI specifications that I test with on other projects to see if I can reproduce this. It could be the parallel IO operations that is killing your machine. If it takes 30 minutes then it might be because of a dead lock when multiple threads are trying to perform IO operations on the same file.

christianhelle avatar May 29 '24 19:05 christianhelle

Thanks for the fast reply. I tested with another swagger.json and worked very fast. I will try to run it again avoiding validation in case there is a problem there.

blogcraft avatar May 30 '24 21:05 blogcraft

@blogcraft I'm working on a timeout feature so it would never run for more than a few minutes. Unless the OpenAPI spec has millions and millions of lines of code (which will most likely introduce an entirely different set of problems...) parsing and generating text based on the input should never take that long

christianhelle avatar May 30 '24 21:05 christianhelle

I haven't solved the actual cause yet but I did introduce a default timeout of 2 minutes for writing to disk so that users won't have to wait indefinitely

christianhelle avatar Jun 03 '24 13:06 christianhelle

I might have found out the issue with the swagger, there seems to be object results that have relationships that go deep down. So, a fix might be limiting how deep an object might go besides the timeout you mentioned.

Example, A GET returns an object A:

ObjectA:
{
  a: string,
  b: string,
  listz: ObjectZ[]
}

ObjectZ:
{
  d: string,
  e: string,
  listy: ObjectY[]
}

ObjectY:
{
  ...
}

blogcraft avatar Jun 04 '24 14:06 blogcraft