-
Notifications
You must be signed in to change notification settings - Fork 22
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
dub: Cache PackageManager across dub{Package,Dependant} targets #281
Conversation
payload/reggae/dub/interop/dublib.d
Outdated
// With this cache here, this means that we only support that | ||
// dir for the first root project, and apply it to all other | ||
// root projects. | ||
cachedPM = super.makePackageManager(); |
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.
@Geod24: Any suggestions? Maybe constructing directly here and feeding it NativePath.init
as root package path?
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.
@Geod24: Looking at https://github.com/dlang/dub/blob/0d4858eb473a31a058132c8692d499effdb1cb28/source/dub/packagemanager.d#L116-L124, it doesn't look like that special <root pkg path>/.dub/packages/
repo can be disabled. Is there a way?
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 AFAICT, I cannot use the reggae project or build directory here either (for a somewhat consistent local .dub/packages
repo, not depending on the order of dubPackage
targets), as each dub root project/config gets a reggae Options
struct with projectPath
and workingDir
both overridden to the dub root project directory. And the original projectPath
is a bunch of calls up:
reggae/payload/reggae/rules/dub/external.d
Lines 123 to 132 in cc9ec99
projectPath = reggaeOptions.projectPath; | |
const path = buildPath(projectPath, dubPath.value); | |
subOptions = reggaeOptions.dup; | |
subOptions.projectPath = path; | |
subOptions.workingDir = path; | |
subOptions.dubConfig = dubPath.config.value; | |
// dubInfos in this case returns an associative array but there's | |
// only really one key. | |
auto output = () @trusted { return stdout; }(); | |
dubInfo = dubInfos(output, subOptions)[dubPath.config.value]; |
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.
The PackageManager
is not designed to handle changing Location
, and was originally designed with 3 hardcoded Location
s, making any kind of extensibility hard (e.g. the PlacementLocation
enum).
Caching the PackageManager
is an option but seems the most hacky one. Another option is to only instantiate one Dub
instance (might require some changes to Dub), or to make package loading lazy. Per and myself have made some progress in the lazy loading, I don't know the Reggae codebase well enough to say how much Dub needs to change to allow for what it does. So ATM I don't have a satisfying answer, sorry.
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.
Okay nevermind, I found a way, and am using the original reggae project directory now.
After some quick tests, this seems to work. On my box, a buildgen runtime (for a |
Seems like it, nice. I've repopulated my dub packages cache on Windows, fetching 111 packages. Then the buildgen runtime of master is ~13.5 secs, and with this PR down to ~10 secs (best of 3 each). That's quite a lot, as 111 dub packages in the cache isn't a lot, and a good portion of that runtime is caused by preGenerateCommands (edit: which are unaffected). Edit: I've also diffed the produced |
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, but I defer to @Geod24 for the final decision.
Why does Reggae need to instantiate more than one Dub instance though ? |
As said, a |
Then I think caching the In the long run, I would like to look into why it needs multiple root packages. The only thing that root package has on a regular package is the dependency resolution / config. Dub can obviously build dependencies without them being root packages so I would expect Reggae to be able to do so as well (conceptually, the API for it is probably terrible). |
One unittest fails because it changes a dub.sdl that it previously built, and rightfully expects reggae to re-generate its configuration after the .sdl change. But caching the PackageManager (for the whole unittest process - per thread) leads to the .sdl not being reloaded. |
faf7ce9
to
4da9e88
Compare
auto lines = runIt("-d myvar=foo"); | ||
srcLine.should.not.be in lines; | ||
cfgLine.should.be in lines; | ||
// we cache dub's PackageManager per-thread; use a new thread to make sure the changed .sdl is reloaded |
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 means the test needs to know waaay too much about the implementation.
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.
Well, the test needs to reparse a changed .sdl, something a real reggae process never does, and I thought this is the least invasive method to make that test still work.
4da9e88
to
32d02e4
Compare
I don't know enough about dub to review this. @Geod24 ? |
I'm more than happy to revise this after according dub API changes; this performance problem is the only real blocker for switching our SIL build to lots of Wrt. the Lazy loading would be super-nice of course, so that the dub packages cache size hopefully wouldn't affect dub performance anymore. |
The one-config-per-root-project approach also doesn't work if we want to solve dlang/dub#1706 and dlang/dub#1217 . |
Well reggae's |
No description provided.