MarkusSintonen

Results 29 comments of MarkusSintonen

> Can you give us a sample of your models? For example, the model from your slowest endpoint with the field names and model names mangled or something like that....

> I've pushed a branch to pydantic called lazy-type-adapter which makes type adapters instantiate the core schemas and validators/serializers lazily. Is there any chance you could try installing pydantic from...

> FastAPI is actually creating another type adapter each time you include a route in another route. As a result, there's a lot of potentially-unnecessary overhead @dmontagu yes I also...

It would be easier to open an improvement PR to FastAPI to reuse TypeAdapters if Pydantic would make `FieldInfo` properly [hashable](https://github.com/pydantic/pydantic/issues/6768#issuecomment-1643659360)/immutable. Then it would be possible to make a cache...

> I usually like things in my web apps to not be lazy because I'd rather have a 10s start than random 500ms latency for users. Yeah I mostly agree....

> could you try [this branch](https://github.com/pydantic/pydantic/tree/walk-perf) and see if it makes any difference Sure, I'll try later today! All in all, I think if we get FastAPI to do TypeAdapter...

> > 10sec startup in tests is livable > > Would 0s (give or take, if we did lazy startup) in tests and 10s in production be even better? Even...

> In the meantime I've been trying to optimize what we do on the Pydantic side. MarkusSintonen could you try [this branch](https://github.com/pydantic/pydantic/tree/walk-perf) and see if it makes any difference? I'm...

@adriangb I wrote a test for you that tries to emulate the performance issue: [test_perf.py.txt](https://github.com/pydantic/pydantic/files/12137152/test_perf.py.txt) Eg it gives similar cProfile results. You can try it out on investigations. Its kinda...

@samuelcolvin / @adriangb FYI we are testing PydanticV2 on our EKS cluster. It has a very noticeable impact on the overall memory usage. Memory usage increases by over 2x. I...