Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Performance for large projects #16

Open
kalawr opened this issue Dec 12, 2018 · 2 comments
Open

Performance for large projects #16

kalawr opened this issue Dec 12, 2018 · 2 comments

Comments

@kalawr
Copy link

kalawr commented Dec 12, 2018

Hi Dillon! Thanks for your great work, we are loving the library! We tried applying the elm-typescript-interop to our project (about 21,000 LOC of Elm), which coincidentally uses elm-graphql too, and the time it takes to parse all of these files and produce the output is way beyond practical. Have you run into performance issues yourself with elm-typescript-interop or heard similar stories? Would love to help you get to the bottom of this and contribute. Thanks!

@dillonkearns
Copy link
Owner

Hello @kalawr! That's great to hear that you're enjoying the library!

I haven't ever run elm-typescript-interop on a project large enough to cause performance issues. I appreciate you reporting the slow performance.

So I've got a few thoughts to explore on how to improve performance here:

  • Currently the project is on 0.18. This is because none of the elm-ast libraries support Elm 0.19 (and it's possible that they won't be upgraded). I'm going to explore using https://github.com/stil4m/elm-syntax. If this works, then it would allow me to upgrade to 0.19 finally, which may improve performance
  • I might consider only parsing files which are imported from a main file. This would require the user to pass in a list of Main modules to use, but this could improve performance. Judging by your particular project, does this seem like it could be a promising path? In other words, about what percentage of files (or lines of code) would need to be parsed if we only parsed modules which are imported from the Main module you are generating a TypeScript definition for (roughly)?

Before exploring any of these, it would be really helpful to get some metrics from you so I can understand the problem better.

To start, could you provide me with the following:

  • The specs on your machine
  • The number of Elm lines of code in your project (you can use something like cloc)
  • The time it takes to run elm-typescript-interop (you can just use time on Unix)
  • If you run it with sysconfcpus -n 1, does the time change?

Thank you!

Dillon

@kalawr
Copy link
Author

kalawr commented Dec 20, 2018

Specs: Windows 10, 64-bit; 20 Gb RAM; Intel i7-5600U 2.60 Hz
LOC: The project contains 23,251 lines of Elm code (as per cloc). For this particular project we are using Prisma and elm-graphql, which results in a considerable amount (18,081 lines) of auto-generated Elm files. My estimate would be around 15% of all files are not linked to the app import tree.
Time: elm-typescript-interop ran for 889.623 s (~15 minutes, benchmarked with ptime) before it exited with an error:

Alias `ValueId` not found. Known aliases:
Api.InputObject.CompanyCreateOneWithoutHierarchiesInputOptionalFields...

However, the project compiles with elm make.
Can't run sysconfcpus -n 1 on Windows, sorry. Should I try to look for a workaround?
We can give you access to the project repo, if it works for you! Really thankful for your time and willingness to help us out.

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

No branches or pull requests

2 participants