-
Notifications
You must be signed in to change notification settings - Fork 697
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
Avoid redundant glob checking #10520
base: master
Are you sure you want to change the base?
Avoid redundant glob checking #10520
Conversation
extraSrcFilesGlobResults <- mapM (checkGlobFile "." "extra-source-files") extraSrcGlobs | ||
extraDocFilesGlobResults <- mapM (checkGlobFile "." "extra-doc-files") docGlobs | ||
extraFilesGlobResults <- mapM (checkGlobFile "." "extra-files") extraGlobs | ||
extraDataFilesGlobResults <- mapM (checkGlobFile rawDataDir "data-files") dataGlobs |
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.
Instead of re-parsing each FilePath
here, we reuse the globs parsed above in checkGlob
.
-- § Missing documentation. | ||
checkMissingDocs | ||
extraDataFilesGlobResults | ||
extraSrcFilesGlobResults | ||
extraDocFilesGlobResults | ||
extraFilesGlobResults |
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.
And instead of re-parsing and then re-running the glob find, we just use the results generated above.
=> FilePath -- Folder to check. | ||
-> CabalField -- .cabal field we are checking. | ||
-> CheckM m () | ||
checkGlobFile cv ddir title fp = do | ||
-> Glob -- Glob pattern. | ||
-> CheckM m [GlobResult FilePath] |
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.
these args are all just String
🤪 and were incorrectly documented before.
Nothing -> | ||
pure [] | ||
Just po -> do | ||
rs <- liftCM $ runDirFileGlobM po dir parsedGlob |
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.
liftCM
was not previously exported, but it is necessary to actually use this if the liftint
interface doesn't suffice - and since that interface has a forced return of ()
, it can't work here.
@@ -37,6 +37,7 @@ module Distribution.PackageDescription.Check.Monad | |||
, checkP | |||
, checkPkg | |||
, liftInt | |||
, liftCM |
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.
If we don't want to expose this I can probably replace with a function like liftInt
but that allows a secondary return, like,
liftIntWith
:: (CheckInterface m -> Maybe (i m))
-> (i m -> m ([PackageCheck], r)
-> CheckM m (Maybe r)
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.
Exposing it is fine.
res <- realGlob esgs | ||
red <- realGlob edgs | ||
ref <- realGlob efgs | ||
concatMap globMatches t |
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.
can simplify this to globMatches t
and rely on callers to concat
the args, too 🤷🏻
BTW the API change label is neither a complaint nor a barrier to getting it into 3.14; it does mean backporting to 3.12 isn't possible. |
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.
Very good @parsonsmatt. Thanks for the patch.
@@ -37,6 +37,7 @@ module Distribution.PackageDescription.Check.Monad | |||
, checkP | |||
, checkPkg | |||
, liftInt | |||
, liftCM |
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.
Exposing it is fine.
This PR modifies the glob logic to avoid doing redundant work. Results of operations are now passed forward into further checks.
Locally, this improves the time for a no-op
cabal repl
from 50s to 32s.Combined with my other PRs on this, I think this whole operation on our large
extra-source-files
will go from 35s to 65ms 😄Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
Template B: This PR does not modify behaviour or interface
E.g. the PR only touches documentation or tests, does refactorings, etc.
Include the following checklist in your PR: