Home Rails slow to reload for a big project
 I'm working with a big Rails 4.2 project and when I do reload! in the console, it's long to run. I measure it by doing Benchmark.measure { reload! }.real and it take 2.5 seconds. It appear to be quick but each time I save a file and run a test or do a request it reload the files so I have kind of results : time spring rspec --color spec/models/content_thread_spec.rb:605 Running via Spring preloader in process 1016 Run options: include {:locations=>{"./spec/models/content_thread_spec.rb"=>[605]}} Randomized with seed 33718 . Finished in 0.16152 seconds (files took 42.45 seconds to load) 1 example, 0 failures Randomized with seed 33718 real 0m1.736s user 0m0.440s sys 0m0.064s c337ecbc2313 app # touch app/models/bla.rb c337ecbc2313 app # time spring rspec --color spec/models/content_thread_spec.rb:605 33 Running via Spring preloader in process 1065 Run options: include {:locations=>{"./spec/models/content_thread_spec.rb"=>[605]}} Randomized with seed 33718 . Finished in 0.17195 seconds (files took 1 minute 3 seconds to load) 1 example, 0 failures Randomized with seed 33718 real 0m4.521s user 0m0.441s sys 0m0.064s  As you can see, it took 1.7 seconds when I didn't change anything and, then I change any file in the project, it take 4.5 seconds. If I run the test once again, it will take 1.7 seconds. All files of the project are reloaded and files I change doesn't have to be related. As I understand, each files are reloaded when I change a file. There is many files and I can see with ActiveSupport::Dependencies.loaded.count there is 803 files to load. It seems than all the files are in ActiveSupport::Dependencies.loaded. All paths are in Rails.configuration.autoload_paths. Is there a way to have a more wise solution and reload only needed files? Does all files have to be loaded?