dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

Sharing violation reading pgd file during concurrent local coreclr builds (windows x86 release) #46018

Open trylek opened 3 years ago

trylek commented 3 years ago

Initial cost estimate: 2 days Initial contacts: @trylek, @jkoritzinsky, @davidwrighton

OS: Windows Architecture: x86 Configuration: Release Repro steps (non-deterministic): build clr+libs+libs.tests -a x86 -c Release in two runtime repo clones

    D:\git\runtime\artifacts\obj\coreclr\windows.x86.Release\vm\wks\cee_wks_obj.dir\Release\ceemain.obj
  LINK : fatal error LNK1266: error reading instrumentation file 'C:\Users\trylek\.nuget\packages\optimization.windows_nt-x86.pgo.coreclr\99.99.99-master-20200806.6\data\coreclr.pgd'; Sharing violation [D:\git\runtime\artifacts\obj\coreclr\windows.x86.Release\dlls\mscoree\coreclr\coreclr.vcxproj]
    Finished generating code
    mscordaccore.vcxproj -> D:\git\runtime\artifacts\obj\coreclr\windows.x86.Release\dlls\mscordac\Release\mscordaccore.dll

  Build FAILED.

  LINK : fatal error LNK1266: error reading instrumentation file 'C:\Users\trylek\.nuget\packages\optimization.windows_nt-x86.pgo.coreclr\99.99.99-master-20200806.6\data\coreclr.pgd'; Sharing violation [D:\git\runtime\artifacts\obj\coreclr\windows.x86.Release\dlls\mscoree\coreclr\coreclr.vcxproj]
      0 Warning(s)
      1 Error(s)

Likely the linker opens the PGD file without the sharing flag so that multiple parallel coreclr builds step on each other's toes. This is happening pretty frequently and degrades local developer inner loop experience. While it seems clearly a linker bug (there's no reason for it to request exclusive / write access to the pgd file), it remains to be seen whether asking for a linker fix would be actionable so we may want to consider a workaround like copying the file to a repo location prior to linking even though it's somewhat unfortunate as the file has 36 MB so that it will probably incur a few seconds' perf penalty.

/cc @dotnet/runtime-infrastructure

ViktorHofer commented 3 years ago

cc @akoeplinger and @marek-safar regarding the linker ask.

akoeplinger commented 3 years ago

@ViktorHofer this is about the native C++ linker, not the managed linker :)

ViktorHofer commented 3 years ago

Haha 😂 thanks for clarifying