-
Notifications
You must be signed in to change notification settings - Fork 696
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
Support Git submodules in source-package-repository #7625
Conversation
00d63e6
to
917ef92
Compare
If you run |
f07c5d7
to
cf5e49a
Compare
@Mikolaj Thanks for the pointer. I found some property tests and added submodule support in there. It uncovered an edge case in git's handling of submodules. Fortunately I was able to work around that 😄 |
@akshaymankar: do the CI failures look relevant or is this only some transient breakage? |
cf5e49a
to
30f716e
Compare
Looks like GHC 8.8 and below couldn't infer the kind of the type level variable I introduced. I have added an explicit annotation now. It at least compiles with 8.8. |
6265820
to
62b6df0
Compare
The older git (2.17.1) in the bionic container is stricter about I also noticed that I wasn't respecting the |
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.
Thank you so much for the tests.
} | ||
| tag <- maybeToList (srpTag repo) ] | ||
++ [ git (resetArgs tag) | tag <- maybeToList (srpTag repo) ] | ||
++ [ git (["submodule", "sync", "--recursive"] ++ verboseArg) |
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.
How much does this, and other more complex git commands you introduced, slow down the cases where there are no submodules or where submodules are handled fine already (are there such cases?). What other risks there are from these more complex commands?
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.
How much does this, and other more complex git commands you introduced, slow down the cases where there are no submodules?
I just tried timing the new commands on the cabal repo and got:
$ time git submodule deinit --force --all
git submodule deinit --force --all 0.03s user 0.04s system 113% cpu 0.056 total
$ time git submodule sync
git submodule sync 0.04s user 0.03s system 109% cpu 0.062 total
$ time git submodule update --init --recursive --force
git submodule update --init --recursive --force 0.03s user 0.04s system 109% cpu 0.066 total
$ time git submodule foreach --recursive "git clean -ffdxq"
git submodule foreach --recursive "git clean -ffdxq" 0.03s user 0.04s system 110% cpu 0.061 total
$ time git clean -ffdxq
git clean -ffdxq 0.00s user 0.01s system 96% cpu 0.011 total
So, with this imprecise test, it seems like this PR may have added extra latency of ~0.15 seconds per repository (which doesn't have submodules).
or where submodules are handled fine already (are there such cases?)
I don't think there were any cases where submodules worked.
What other risks there are from these more complex commands?
I can see this becoming a breaking change for some setup where a package repository submodules a private repository which is not needed for compiling haskell. To support this, a flag might be required to disable submodule fetching.
I can't think of any other risks.
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 can see this becoming a breaking change for some setup where a package repository submodules a private repository which is not needed for compiling haskell. To support this, a flag might be required to disable submodule fetching.
How do you feel about waiting with that flag until we get actual reports that people need it? Is there a workaround for such people in the absence of the flag?
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 am OK with waiting for the flag.
As a work around maybe people could maintain forks of of depedencies which remove such submodules, but this would be very inconvenient for repositories which need to be updated a lot.
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.
So finally we will not have the flag to hide the new feature?
Out of curiosity, did you test it (performance oriented) with large git repos with many submodules?
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 tested it with a large git repo, there wasn't much difference, most time was just spent first time cloning the base repo. The repo had 3 submodules, which were all small, so fetching them was comparatively quick.
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.
LGTM and the overhead and risks seem acceptable, though my knowledge of the matter is limited (e.g., I can't imagine corner cases and I have no idea how many projects currently use the features and may either benefit from this PR or may need to adjust to it).
If nobody reviews this soon, I'm going to abuse my privilege and merge it alone. Please don't make me a worse person. |
i am gonna try it in windows with a hls version which had submodules: https://github.com/haskell/haskell-language-server/tree/e4f677e1780fe85a02b99a09404a0a3c3ab5ce7c (only one) do you know some haskell repo with a good amount of submodules? |
The build has been succesful in my windows machine. 💯 |
well a corner case would be use a s-r-p without subdir which has source dirs (or other dirs needed for the build) as submodules (or use a subdir which has source dirs as submodules) 🤔 maybe a flag to enable submodules would make more sense out of scope of this pr (and not asking for a change): maybe the more generic way would be let user tell cabal what concrete git commands would be needed to get the s-r-p, via a script or something |
BTW, I've been told this project is a good test of a possible slowdown for projects with no submodules, because it has so many If this test shows there is no problem, I'm fine accepting the PR and we'd worry when users with unused submodules complain (but they may be willing to accept some slowdown in unused modules for convenience in used submodules; also the scheme with submodules tends to make caching rebuilds harder, so that's not the route to take if somebody prioritizes (re)compilation speed --- the link above [edit:probably] is the current optimum, as verbose as it is). [Edit: also, if I understand correctly, checking out unused submodules happens only once, right? Not on rebuilds of the project?] |
@akshaymankar i labeled with info-needed to reflect @Mikolaj request for manual testing perf over a repo with lot of s-r-p |
@akshaymankar: I'm aware this review drags on for a month now. Please let us know if you have a deadline or if you are just fed up already. :) We are quite stretched, hence the delay, but we appreciate contributions all the more and we would hate to discourage yours. |
I understand that OSS contributions can take some time to get responses. So, I am not fed up yet 😄 |
Hello, I finally found time!
This shows about 1-2 second slowdown on first two runs of |
@akshaymankar: amazing. Let's fire the rockets! |
@Mergifyio rebase |
The `RepoRecipe` type now takes a type level argument which tells the arbitrary instance whether to allow submodules in the recipe or not.
✅ Branch has been successfully rebased |
This PR tries to solve #5536. I tried to use
--recurse-submodules
flags inclone
andreset
but they don't work very well when the repo is cloned with--no-checkout
. So, I just implemented the solution discussed in the issue, this includes changingcheckout
toreset --hard
.Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!
I manually tested this in two ways:
cabal
from this fork and see if the repository gets cloned correctly and the project compiles.I am not sure where to add automated tests for this. I would be happy to add them if someone points me to the place to add them.