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

massive increase in expanded code size for deriving.show #292

Open
oandrieu opened this issue Nov 14, 2024 · 1 comment
Open

massive increase in expanded code size for deriving.show #292

oandrieu opened this issue Nov 14, 2024 · 1 comment

Comments

@oandrieu
Copy link

While using [@@deriving show] on a not-so-small-ish AST (~ 100 type declarations with a large clump of 60 mutually recursive types), I see that switching from ppx_deriving 5.2.1 to 6.0.3 resulted in massive increase of the code size after preprocessing.

With a ppx_deriving 5.2.1, there's rougly a ×3 file size increase, but with 6.0.3 it's more like ×100 and then the OCaml compiler fails with a stack overflow. In the output I see that many pretty-printing functions are repeated multiple times.

It's unclear to me if I'm using the annotations incorrectly, or using the ppx incorrectly.
(I'll try to come up with a repro case.)

@oandrieu
Copy link
Author

oandrieu commented Nov 14, 2024

Oh OK, I understand, that's because I have a deriving annotation on every typedef in a mutually recursive type definition:

type tutu =
  | VARIANT1
  | VARIANT2 of tutu
[@@deriving show]

and toto =
  { fielda : bool
  ; fieldb : tutu
  }
[@@deriving show]

I wasn't aware the annotation was only needed on one of the typedefs.
Still, the redundant annotations were harmless in ppx_deriving 5.2.1. Is this intended ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant