I have some pretty big resources in my code base that takes more than 10 seconds to compile, after profiling it a bit, I noticed that the compile time would go down a lot if I remove the code_interface block from it.
For example, one of my resources have this code_interface:
code_interface do
define :create
define :create_with_lead
define :create_live_transfer
define :create_fake
define :create_with_photo_upload
define :update
define :photo_requred_now
define :send_photo_upload_request
define :request_photo_upload_from_seller
define :modify_appointment
define :cancel
define :cancel_fake
define :reschedule
define :get
define :get_admin
define :get_own
define :get_by_lead
define :get_by_property_registry
define :get_by_attom_id
define :list_own
define :list_between_dates
define :list_admin
define :list_by_address
define :priors
define :sign_appointment
end
When compiling the resource with the code_interface, it would take around 11 seconds:
`[profile] 11260ms compiling + 0ms waiting while compiling lib/core/marketplace/ap/appointment.ex`
If I remove the code_interface, then it goes down to 2 seconds:
`[profile] 2270ms compiling + 0ms waiting while compiling lib/core/marketplace/ap/appointment.ex`
I also tried to move the code interface to the domain:
resource Ap.Appointment do
define :create_appointment, action: :create
...
define :sign_appointment, action: :sign_appointment
end
With this in the domain, the domain took 6 seconds to finish:
[profile] 6397ms compiling + 0ms waiting while compiling lib/core/marketplace/ap.ex
And without it, it would take only 285ms:
[profile] 285ms compiling + 0ms waiting while compiling lib/core/marketplace/ap.ex
So, here is the question, is this expected? Can this be optimized in some way? It took me by surprise how slower the compilation is when having a code interface (either in the resource or in the domain).
I’m literally considering remove all code interfaces from my code base to make it compile faster, but I would like to know if this is just a optimization “bug” that can be fixed or it is expected.




















