-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add "cache add" functionality to project caching - Attempt 2 #9214
Add "cache add" functionality to project caching - Attempt 2 #9214
Conversation
…tnet#9188)" This reverts commit 3c910ba.
This reverts commit 180ff51.
This reverts commit 79ad288.
This reverts commit 70b4bcf.
ManualResetEventSlim handle = _fileAccessCompletionWaitHandles.GetOrAdd(globalRequestId, static _ => new ManualResetEventSlim()); | ||
handle.Set(); | ||
} | ||
else if (_tempDirectory != null && fileAccessPath.StartsWith(_tempDirectory)) |
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 StartsWith
is culture specific while the previous one is ordinal.
/// </summary> | ||
/// <param name="fileAccessData">The file access to report.</param> | ||
[CLSCompliant(false)] | ||
public virtual void ReportFileAccess(FileAccessData fileAccessData) => throw new NotImplementedException(); |
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.
Did you consider making this parameter in FileAccessData
? This is a 9 member struct
which means every call to this API is going to involve a lot of copies. This API is going to be called a lot in a tight loop for non-trivial build operations so it's one where efficiency may be important.
Handlers[] localHandlers = _handlers; | ||
foreach (Handlers handlers in localHandlers) | ||
{ | ||
handlers.FileAccessHander.Invoke(buildRequest, fileAccessData); |
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 is another case where we're copying a large struct
in a loop (this is nested in another loop so even more copies).
/// <inheritdoc/> | ||
public void Translate(ITranslator translator) => translator.Translate(ref _fileAccessData); | ||
|
||
internal FileAccessData FileAccessData => _fileAccessData; |
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 is a place you should consider using
intenal ref readonly FileAccessData FileAccessData => ref _fileAccessData;
Otherwise you're doing a full copy just to access one or two members.
{ | ||
private FileAccessData _fileAccessData; | ||
|
||
internal FileAccessReport(FileAccessData fileAccessData) => _fileAccessData = fileAccessData; |
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.
Another place to consider in FileAccessData
/// Called for each file access from an MSBuild node or one of its children. | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
public virtual void HandleFileAccess(FileAccessContext fileAccessContext, FileAccessData fileAccessData) |
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 use in
here
/// Called for each new child process created by an MSBuild node or one of its children. | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
public virtual void HandleProcess(FileAccessContext fileAccessContext, ProcessData processData) |
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 use in
here
/// <inheritdoc/> | ||
public NodePacketType Type => NodePacketType.ProcessReport; | ||
|
||
internal ProcessData ProcessData => _processData; |
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.
A place where you can use ref readonly
to alleviate copies
internal ref readonly ProcessData ProcessData => ref _processData;
{ | ||
private ProcessData _processData; | ||
|
||
internal ProcessReport(ProcessData processData) => _processData = processData; |
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 use in
here
Handlers[] localHandlers = _handlers; | ||
foreach (Handlers handlers in localHandlers) | ||
{ | ||
handlers.ProcessHandler.Invoke(buildRequest, processData); |
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.
Copying a large struct in a loop
This is a redo of #8726, but with fixes to make the changes acceptable for VS insertion.