sezaru
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.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
Wow, that is pretty damn hefty!
Honestly I’d be willing to bet that we can optimize this. Could you perhaps put together a sample project showing these slow compile times? I could go in and hunt down problems and clean things up. One such example is that the code interface logic is not really the greatest macro code anyone ever wrote, I wrote it pretty early on and I know a lot more than I did back then
sezaru
Here it is @zachdaniel GitHub - sezaru/test_slow_code_interface · GitHub
To test it, you need to compile with profile set, basically run
mix compile –profile timeThen, in the
lib/test/my_domain.exyou can change theifto enable or disable the code interface definitions.You can also do the same with the resource in
lib/test/my_domain/my_resource.exHere are my numbers:
MyResourcewithcode_interface:[profile] 4148ms compiling + 0ms waiting while compiling lib/test/my_domain/my_resource.exMyResourcewithoutcode_interface:[profile] 533ms compiling + 0ms waiting while compiling lib/test/my_domain/my_resource.exMyDomainwithcode_interface:[profile] 3719ms compiling + 0ms waiting while compiling lib/test/my_domain.exMyDomainwithoutcode_interface:[profile] 368ms compiling + 0ms waiting while compiling lib/test/my_domain.exsezaru
hey @zachdaniel any insights regarding this? Were you able to reproduce the issue with the project I created in the post above?
zachdaniel
I’m hoping to look into this this weekend.
zachdaniel
@sezaru should be some pretty significant improvements in
mainofash. Please give it a shot and let me know the resultsDGollings
For us trying out
mainwas a massive improvement, from ~32s to ~9s, thanks @zachdanielsezaru
Working great for the as-well! From 18 seconds in a resource to around 6s. Thanks again