-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remove usages of TaskQueue #76453
Remove usages of TaskQueue #76453
Conversation
} | ||
|
||
File.AppendAllText(_logFilePath, _buffer.ToString()); | ||
_buffer.Clear(); |
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.
It looks like _buffer can go away at this point; before it was collecting stuff until it got written, now it's just being used as a local here. And we could just directly do the writing to a file to avoid the giant string allocation.
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.
Looks like it's trying to do a single write, instead of N smaller writes. I have no issue keeping this.
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 kind of like Jason's suggestion too, it can still be a single call into the File API, something like:
var now = DateTime.Now;
File.AppendAllLines(_logFilePath, list.Select((functionId, message) => $"{now} ({functionId}) : {message}"));
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 we separate out core parts of PRs, vs nice to haves? I'm fine with potentially making this change in a future PR, or having one of you guys do it. The core goal here is simplifying the threading primitives. I don't want to be iterating a lot on making extra changes that take away from that work.
Please separate out nits and suggestions, from requirements for a PR to go in. Thanks @jasonmalinowski @ToddGrun
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.
@CyrusNajmabadi Even if we don't want to optimize, at least move _buffer to a local. Otherwise we're leaving a field around that doesn't need to be a field, and looks like there's more complexity than there is.
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 make this change in a followup PR.
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.
Done in 052c7ee
No description provided.