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
Add candidates method as CURI recommendation manager #1125
Conversation
Add `method candidates` - All distribution searching/resolving go through this new method. This gives developers insight into how a CURI resolves a module request, which was not possible with .resolve (since it would chain to the next CUR, and only returned a single result). Many NYI s22 features will require something like this, and .candidates is indeed mentioned in s22 https://design.perl6.org/S22.html#candidates !matching-dist is now backed by .candidates, but also caches a single 'best match' so it acts similar to before. .candidates (i.e. !matching-dist) now returns a Distribution object and not ($dist-id, $dist-data). This is possible because of a role that allows our lazy distribution to avoid yet additional costly IO calls to obtain meta data. Previously this was done by passing around a hash internally, but now we dogfood our Distribution interface throughout CURI. Avoid io after setting up various directories once. Removes .script, and reverts to using just .files - .script was just a fast path of .files under certain conditions and lacked the ability to filter by name. Now .files can provide the faster path for other files automatically. Additionally this fixes an issue where .script would invoke older version bin/ scripts from ~/.perl6 Adds :$api field wherever it was missing for consistency.
| :version($dist<ver>), | ||
| :auth($dist<auth> // Str), | ||
| :version(.meta<ver>), | ||
| :auth(.meta<auth> // Str), |
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.
I wonder: does CompUnit still need :version and :auth now that these can be provided via $cu.distribution.meta<ver>? Or maybe we should use the distribution, if provided, to provide default values for those fields?
|
My standard benchmark (require GTK::Simple) does not show any change outside the margin of error :) |
|
But this is not good :( Happens to a zef installed on nom after switching rakudo to your branch. |
It made sense for the .files/.candidates api to take an explicit bin/ (if looking for bin/foo). It could make sense for this .run-script + wrapper, but it also make sense without since the method name implies the name-path prefix is a bin/ script. Since a rakudo installation can be upgraded with distributions (i.e. bin/ scripts) already installed we should continue to use the current behavior of an implicit bin/ prefix.
Even if this doesn't result in a obvious speed increase, it has the ability to. Consider that a lazy Distribution may eventually end up parsing json (its slow path) to fill out the rest of its fields (anything that isn't name/auth/ver/source/checksum) - once this happens we may as well serve all future requests with those fields so they don't have to do another parse.
Sometimes the lookup file may not contain the source id. In these cases we need to fall back to the slower json-parsing code path. This also revealed a bug where old meta data was being returned for a LazyDistribution after the first json parsing.
See #1125 for .candidates details Creates full Distribution for both -I. and -Ilib, where the later will use the directory recursion it was already doing (to determine id) to automatically populate meta data for provides and files (bin/, resources/). Makes it possible to do `sub MAIN("version") { $*REPO.need("My::Module").distribution.meta<ver> }` to allow scripts to give the right version regardless of CURI or CURFS being used to load it.
Prerequisites: rakudo/rakudo#1125 rakudo/rakudo#1132
If a distribution is not found then do not cache the value. This allows run time module installations to be found with resolve/candidates.
Name meta data variables $meta instead of $dist
Add
method candidates- All distribution searching/resolving gothrough this new method. This gives developers insight into how a
CURI resolves a module request, which was not possible with .resolve
(since it would chain to the next CUR, and only returned a single
result). Many NYI s22 features will require something like this, and
.candidates is indeed mentioned in s22
https://design.perl6.org/S22.html#candidates
!matching-dist is now backed by .candidates, but also caches a single
'best match' so it acts similar to before.
.candidates (i.e. !matching-dist) now returns a Distribution object
and not ($dist-id, $dist-data). This is possible because of a role
that allows our lazy distribution to avoid yet additional costly IO
calls to obtain meta data. Previously this was done by passing around
a hash internally, but now we dogfood our Distribution interface
throughout CURI.
Avoid io after setting up various directories once.
Removes .script, and reverts to using just .files - .script was just
a fast path of .files under certain conditions and lacked the ability
to filter by name. Now .files can provide the faster path for other
files automatically. Additionally this fixes an issue where .script
would invoke older version bin/ scripts from ~/.perl6
Adds :$api field wherever it was missing for consistency.