New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide instant feedback when booting Rails #31434
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
a4e6481
to
c84c5e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a simple and completely reasonable change. I agree that it's an improvement (though I am bothered more than I should be by the fact that you type faster in one gif and that they are different lengths :P)
Can you rebase?
@sgrif Way ahead of you. 😛 I'll redo the GIF. |
I'll defer this to @dhh. I find it unnecessary, but I'm not a UX expert. |
This is also going to show in What is a Rails boot? will now appear. |
@rafaelfranca Fair point which can easily be addressed by non-language feedback like dots. Package managers which need a lot of time to do graph dependency resolution do this very well either with animated or static feedback. |
What does the experience of running a randomized test suite look like?
? |
@derekprior Looks cute to me. 😄 But we can probably find ways to disable this when it's not appropriate. Again this is something that could be addressed by using a loading cursor/symbol rather than text. |
I agree that this should only appear for |
Actually to be more specific, I think it should really show up in any context that |
Adding it right before this line should work:
|
@sgrif @eugeneius That would be too easy, sadly. 😃 The reason feedback in
|
Since I can't really put this feedback after @derekprior At the least the rspec-rails feedback makes sense:
|
Library (and by extension config) files have no business writing directly to stdout/err -- I recently ranted at one of our dependencies for doing so. More generally, I'd argue that this is how console applications work... and note that I don't particularly want to take the blame for whatever portion of that time is actually "Booting Bundler". |
@matthewd I agree with the general sentiment, but as you mentioned this is a CLI. We aren't doing this on |
@sgrif this is not a CLI. If it were only happening on |
I am 100% on board with implementing this so that it only occurs when running |
@matthewd While you seem to focus on the issue of "taking the blame" I'm concerned about end-users of Rails not receiving any indication that a rails command (whatever it does behind the scenes) is not responding for 5 to 10 seconds. I find that a very poor experience regardless of who or what is to blame for the delay, and a simple acknowledgement that the command has any effect is the least I feel Rails can do. Now when it comes to only giving this feedback when To me that's a price worth paying. I hope I can convince others. 😄 |
Like it for console and server 👍 |
Suggesting that I'm "focused" on blame, to the detriment of users, just because I've brought it up is not a particularly productive approach to this discussion. Rails is widely maligned as big and slow, and explicit attribution of the startup time to "Booting Rails" feeds that narrative. Your gif shows the command taking about 1.5 seconds, by my estimate. Is it sped up? That would seem to defeat the point of what it's showing. If you're trying to address a 5-10 second wait that manifests on larger applications, then we should look at where that time is being spent. It may be far easier to get a message out, from an appropriate place, at the one second mark than at zero seconds -- and I think that would be a fine trade-off. If this can't be after
What is the non-"least" you feel we can do? |
I've noticed during pair/mob programming sessions with peers that despite the speed boosts provided by Bootsnap and Spring, there is a noticeable latency between firing a bin/rails server command and any feedback being provided to the console. Depending on the size of the application this lack of feedback can make it seem like something is wrong when Rails is simply busy initializing. This change may seem gratuitous but by just printing one line to STDOUT we're giving a clear signal to the Rails user that their command has been received and that Rails is indeed booting. It almost imperciptibly makes Rails feel more responsive. Sure the code doesn't look very fancy but there's no other appropriate place I could think of putting it than boot.rb. Compare these two GIFs of booting without and with this change: Before: ![Without Boot Feedback](https://user-images.githubusercontent.com/65950/33964140-721041fc-e025-11e7-9b25-9d839ce92977.gif) After: ![With Boot Feedback](https://user-images.githubusercontent.com/65950/33964151-79e12f86-e025-11e7-93e9-7a75c70d408f.gif)
c84c5e8
to
acc03bb
Compare
I've updated the code to only fire on variants of
And I've tested the timings before or after With boot feedback at the top of
With boot feedback at the bottom of the
|
Having this code in |
@kaspth Feels off to me too because boot.rb is so clean but I couldn’t find a drawer to hide this in. Still seems like we have this file and it can do useful work if we don’t overthink it. |
This looks fine to me. I agree that it feels weird to put it in this file, but there's really not a more obvious place to put it. The implementation doesn't handle someone writing |
@matthewd Sorry for not answering you earlier.
I'm sorry for making you out to sound like you didn't care about users. There's been a lot of bike-shedding about a really small change here so I think you can see how I might have perceived everyone focusing on everything negative. The GIFs aren't sped up. It's a production app with 70KLOC with 253 Gemfile dependencies. I ran
I believe that's far beyond the scope of this PR, but I agree that it's worthwhile. I disagree that getting a message out later, or in a more appropriate place is solving the problem I'm attempting to address here.
I don't think that makes it a non-starter, but my logging in #31434 (comment) shows that there's (at least) 381 milliseconds between the command being issues and the feedback when we .3 seconds is beyond the .1 second perceptual barrier for user-initiated actions to feel instantaneous.
https://www.nngroup.com/articles/powers-of-10-time-scales-in-ux/ I'm not arguing Rails should feel instantaneous, but we can try to give users as fast a feedback about their actions as possible in the command line.
Differentiating Rails boot time from Bundler require time would be good and educational. It would subtly help users learn the impact of a bloated Gemfile and I think it would help avoid what you were worried about — people conflating Rails speed and Bundler/Gem require speed. That said, that is definitely beyond the scope of this PR. If you're interested in trying to address that I think it would be worthwhile although it might require some coordination with the Bundler team. I'm not sure if we can get timing data from |
A small note on this: Checking for ARGV doesn't work when you start the app using the server command instead of |
Before:
After:
I've noticed during pair/mob programming sessions with peers that
despite the speed boosts provided by Bootsnap and Spring, there is a
noticeable latency between firing a bin/rails server command and any
feedback being provided to the console. Depending on the size of the
application this lack of feedback can make it seem like something is
wrong when Rails is simply busy initializing.
This change may seem gratuitous but by just printing one line to STDOUT
we're giving a clear signal to the Rails user that their command has
been received and that Rails is indeed booting. It almost imperciptibly
makes Rails feel more responsive.
Sure the code doesn't look very fancy but there's no other appropriate
place I could think of putting it than boot.rb.