-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[vcpkg] Use named mutex to serialize dll copies #11363
Conversation
Hi @thomasgt, please resolve the conflicts. Thanks. |
40245e8
to
cf2802d
Compare
Sure, just rebased onto master. |
} | ||
finally | ||
{ | ||
$mtx.ReleaseMutex() | Out-Null |
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.
Technically this needs a null check but I doubt we care...
I didn't look closely enough at the resolve function. It calls itself recursively. I guess |
On the other hand, I guess if other scripts make use of the resolve function, maybe it's better to keep this serialization logic inside? The only usages I've found are from port specific deploy functions that are called from within resolve itself. Just let me know what you think and I'll update accordingly. |
@thomasgt It's not documented, afaict, whether |
596d44f
to
4a95403
Compare
@strega-nil Done. Let me know if there's anything else I can clean up! |
finally | ||
{ | ||
if ($mtx) { | ||
$mtx.ReleaseMutex() | Out-Null |
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.
We shouldn't ReleaseMutex unless WaitOne succeeded.
@@ -90,6 +90,24 @@ function resolve([string]$targetBinary) { | |||
Write-Verbose "Done Resolving $targetBinary." | |||
} | |||
|
|||
function copyRuntimeDependencies([string]$targetBinary) { | |||
try { | |||
$mtx = New-Object System.Threading.Mutex($false, "VcpkgAppLocalResolve") |
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.
We should probably include the current vcpkg path in here somehow so that totally different vcpkgs don't step on each other.
(Before I knew that we recursively used this when building some ports in vcpkg I was less concerned :) )
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.
Alternately: Should we protect deployBinary on a per binary basis rather than the overall resolution step?
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.
Protecting deployBinary might be a better approach, actually. We could scope the Mutex to a combination of deployBinary's $targetBinaryDir and $targetBinaryName arguments? In that case, there would be no need to include the vcpkg path.
Please merge the latest changes into this branch. |
@thomasgt Are you interested in addressing the above CR comments? |
@BillyONeal This slipped my mind... Yes, I'd be happy to tidy this up next week. I'll take the approach of serializing deployBinary as I alluded to in my reply a few months back. |
Sounds good, thanks :D |
08bebfa
to
c5bfd27
Compare
c5bfd27
to
5bb2024
Compare
OK, finally tidied this up. I am scoping the mutex to the target directory, which should let simultaneous builds using vcpkg work as normal, unless they are writing to the same target directory, in which case the DLL copies will be serialized. |
ping @BillyONeal for review this PR. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@JackBoosY Can you mark status:reviewed in the future if you want the "on call" person to take a look? That way others can see too. Thanks! |
Thanks for your contribution! |
Serialize deployBinary on target directory (microsoft#11363)
Fixes #11089
I'm not sure if this is the best idea, but it does seem to prevent multiple parallel build workers from clobbering a common
CMAKE_RUNTIME_OUTPUT_DIRECTORY
when copying runtime deps viaapplocal.ps1
.