ash icon indicating copy to clipboard operation
ash copied to clipboard

Initiative: Reduce compilation time

Open chazwatkins opened this issue 5 months ago • 4 comments

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

AI Policy

  • [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Is your feature request related to a problem? Please describe.

Ash currently has 187 compilation cycles, which causes slower compilation time and most of the project to recompile for even small code changes.

This issue will be used to track the progress and for discussions on the changes.

Describe the solution you'd like

Refactor modules to reduce compilation cycles

Constraints

  • No impact to public apis
  • No change in functionality
  • Only convert from compile-time to runtime when absolutely necessary and runtime performance is not significantly impacted

Describe alternatives you've considered

No response

Additional context

No response

chazwatkins avatar Aug 09 '25 19:08 chazwatkins

PR #2266 Reduced compilation cycles by 2 (187->185)

chazwatkins avatar Aug 09 '25 19:08 chazwatkins

Current Stats

$ mix xref graph --format stats --label compile-connected

Tracked files: 534 (nodes)
Compile dependencies: 506 (edges)
Exports dependencies: 414 (edges)
Runtime dependencies: 1230 (edges)
Cycles: 185

Top 10 files with most outgoing dependencies:
  * lib/ash/resource/dsl.ex (74)
  * lib/ash/filter/filter.ex (45)
  * lib/ash/type/registry.ex (30)
  * lib/ash/reactor/reactor.ex (15)
  * lib/ash/policy/authorizer/authorizer.ex (12)
  * lib/ash.ex (10)
  * lib/ash/embeddable_type.ex (8)
  * lib/ash/domain/dsl.ex (8)
  * lib/ash/resource.ex (6)
  * lib/ash/resource/validation/builtins.ex (5)

Top 10 files with most incoming dependencies:
  * lib/ash/expr/expr.ex (39)
  * lib/ash/type/type.ex (32)
  * lib/ash/query/function/function.ex (28)
  * lib/ash/resource/change/change.ex (23)
  * lib/ash/resource/validation.ex (18)
  * lib/ash/query/query.ex (15)
  * lib/ash/options_helpers.ex (13)
  * lib/ash/resource/calculation/calculation.ex (10)
  * lib/ash/query/operator/operator.ex (9)
  * lib/ash/domain/domain.ex (9)

chazwatkins avatar Aug 09 '25 19:08 chazwatkins

@zachdaniel I saw you had to put in a fix - 0fb406a - for #2271 - after my PR #2271 that potentially introduced this issue. If you have time and wouldn't mind sharing what caused this and how the changes you made resolved the problem? It would help greatly to when considering changes for other macros for compilation time.

chazwatkins avatar Aug 12 '25 11:08 chazwatkins

@chazwatkins no that never worked, it was nothing to do with you 😄

zachdaniel avatar Aug 12 '25 15:08 zachdaniel