-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Yard rake task is missing require #1597
Comments
This is by design. You should not be reaching into and requiring any files from the YARD package other than require 'yard'
YARD::Rake::YardocTask.new |
Understood. I saw that when reading up on install, but assumed it was the "simple, but malperformant" setup that naive rake users typically fall into. It's common to see many gems document the "simple" setup that requires their entire lib in the rakefile, only to later discover the performance impact that has on shell completion ( The common convention is to have a rake task entrypoint that only defines the task, without requiring the library. (gems that do this include: (I'm overly stating things, just to be clear on expectations and assumptions.) The way I ended up defining the task was:
Comparing the two approaches (the above vs: yielded (collected with
16ms isn't a lot, but it's a lot more than 0.2ms Also tested with ruby-prof (Measure Mode: wall_time):
Still about 2 orders of magnitude. Would you consider a request to have an "official" rake entrypoint that didn't set up all of yard? (I realize it's only configuring autoloads and a few things, but it's quite a bit more than the tasklib needs.) I would find this to also be helpful for consumers who look for patterns in Rakefiles and, seeing |
How are you generating this benchmark? This isn't something I can reproduce. Something looks very off about those numbers given that I've never seen a sub-ms Here's what I see:
Running this a number of times is fairly consistent-- requiring the task file directly takes anywhere between 2.5ms - 4ms, while requiring There is probably a risk of disk cache miss where loading YARD can take a little longer, but usually this only happens once and accounts for a very small total cost of your total runtime. If the concern is that YARD will slow down the running of other tasks, then this one time possible disk cache miss is unlikely to be the primary contributor-- an extra ~20ms every 100 or so runs doesn't seem significant for the benefit of significantly improved backwards compatibility guarantees. tl;dr you're free to use the "unsupported" path of directly requiring into YARD if you really need to tightly optimize your Rakefile load time. I think the approach you're using is perfectly reasonable if the load time is that stark on your machine. I don't see enough of a performance gap in the general case to justify increasing YARD's maintenance surface area for the whole project, though. |
Steps to reproduce
The yard rake task is not self-contained and is missing requires to yard itself.
rake yard
taskActual Output
Expected Output
I expected roughly the same output as
yard
It seems the yard task is missing requires.
Environment details:
ruby -v
): ruby 3.1.6p260 (2024-05-29 revision a777087be6) [arm64-darwin23]yard -v
): yard 0.9.37I have read the Contributing Guide.
The text was updated successfully, but these errors were encountered: