The Crystal Programming Language Forum

Reduce compilation time during development?


Please, some tips to reduce compilation time during development?
The bigger a project gets, the longer it takes to save each file => compile => see the result.

It’s normal, but very long. For example, during development, I have one project in Crystal that takes about 20 seconds to compile and another (smaller) project 10 seconds.

Any tip is welcome

Keep an eye on crystal i by asterite · Pull Request #10910 · crystal-lang/crystal · GitHub

It’s not released yet, but looks very promising in regards to fast feedback loop during development.

1 Like

20 seconds sounds like a lot. How many LoC and shards do you have in your project?

Indeed :slight_smile:
A complement of that Why is Crystal language faster than Ruby language? - #4 by nico

Yes, it’s a productivity killer. I migrate the project 1 which is in early stage.
Project 2 is too advanced so we continue as is for now.

Project 1

  • Time to compil (dev): about 10 seconds
  • LoC: 1519 lines
  • Lib directory: 39 shards (LoC: 105345 lines)

Project 2

  • Time to compil (dev): about 20 seconds
  • LoC: 13264 lines
  • Lib directory: 26 shards (LoC: 74058 lines)

Since the second project has about the same LoC but takes 2x as much time to compile, I wonder if maybe there are some big arrays/hashes in code?

There is an issue and an easy workaround if that’s the case Extremely slow compilation and high ram usage for large Arrays and Hashes · Issue #5792 · crystal-lang/crystal · GitHub

I don’t have a big array to populate but it’s something to consider, thanks