prisma-engines icon indicating copy to clipboard operation
prisma-engines copied to clipboard

Skip serializing falsy values to DMMF

Open revmischa opened this issue 3 years ago • 6 comments

Motivation

Shrink the size of DMMF JSON by making implicit what is currently explicit. Assume non-present values are false.

See: https://github.com/prisma/prisma/issues/10724#issuecomment-1073741619

c.f. https://github.com/prisma/prisma/pull/12454

revmischa avatar Mar 21 '22 12:03 revmischa

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 21 '22 12:03 CLAassistant

Hey @revmischa, thanks for the PR! I really appreciate the intention and it's an interesting idea to compress inferable information.

We're not ready to merge this right now because we have a couple ideas to solve this better and tweaking the data structure between Client and Engine could have unforeseen consequences. It's definitely doable to update the client to infer missing fields as false, but would require more investigation and tests.

We have other ideas we'd like to try first:

As Pierre mentioned, we're looking into ways of either eliminating this data structure altogether or making it much smaller.

I'd like to keep this open in case the other solutions don't pan out.

matthewmueller avatar Mar 25 '22 14:03 matthewmueller

I understand the challenge in changing the interface of a data structure used by multiple consumers. My (big) assumption was that the consumers will treat a missing value as false which is why I only elided false values. But I have no idea if that assumption is true or not, hoping someone more knowledgable can shed some light on that.

revmischa avatar Mar 25 '22 15:03 revmischa

Hey @revmischa, thank you for submitting this PR! Prisma has made a lot of improvements in terms of cold start time since the PR was created - sorry for taking so long to get back to you.

Before we dive into technical details, can you please confirm that you can still reproduce the large DMMF causing cold start issues in serverless environments?

laplab avatar Mar 15 '24 13:03 laplab

Prisma cold start is a little better since when I created this issue but it's still a big problem for my application. I don't have recent profiling information right now but I'd estimate prisma adds around 1.5s roughly.

revmischa avatar Mar 15 '24 16:03 revmischa

Thank you for sharing that, @revmischa. Do you know if this happens specifically because of the DMMF file size? We would like to make sure that this PR solves the root cause of your problem before merging it.

If that is no longer the case and you believe there is some other reason for long startup time, I suggest opening an issue about it.

laplab avatar Mar 19 '24 11:03 laplab

Hey @revmischa, we are going to close this PR for now. If you ever get some time to finish it, please feel free to open a new one.

laplab avatar Apr 02 '24 09:04 laplab