Skip to content
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

Minor stress improvement #57715

Merged
merged 3 commits into from
Aug 19, 2021
Merged

Conversation

ManickaP
Copy link
Member

@ManickaP ManickaP commented Aug 19, 2021

  • log S.N.Quic
  • pool string builder
  • shared logs dir
  • updated msquic reference to 1.7.0
  • updated dockerfiles to the current runtime main TFM being 7.0

None of this is critical and can be scratched. I'm just pushing changes that I've done for my own testing.

@ghost
Copy link

ghost commented Aug 19, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details
  • log S.N.Quic
  • pool string builder
  • shared logs dir

None of this is critical and can be scratched. I'm just pushing changes that I've done for my own testing.

Author: ManickaP
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@ManickaP ManickaP requested review from antonfirsov, CarnaViire and a team August 19, 2021 07:47
@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-http

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-ssl

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines 119 to 122
string s = sb.ToString();
sb.Clear();
Interlocked.Exchange(ref _cachedStringBuilder, sb);
await _messagesChannel.Writer.WriteAsync(s, _stopProcessing.Token);
await _messagesChannel.Writer.WriteAsync(sb.ToString(), _stopProcessing.Token);
_stringBuilderPool.Return(sb);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does StringBuilderPooledObjectPolicy clear the StringBuilder now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, thanks! One suggestion.

private int _lastLogNumber = 0;
private FileStream _log;
private Channel<string> _messagesChannel = Channel.CreateUnbounded<string>();
private Task _processMessages;
private CancellationTokenSource _stopProcessing = new CancellationTokenSource();
private const string LogDirectory = "./clientlog";
private ObjectPool<StringBuilder> _stringBuilderPool = new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());
Copy link
Member

@antonfirsov antonfirsov Aug 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since we don't really need the abstraction, we can use the specific type & devirtualize the method calls:

Suggested change
private ObjectPool<StringBuilder> _stringBuilderPool = new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());
private DefaultObjectPool<StringBuilder> _stringBuilderPool = new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());

@antonfirsov
Copy link
Member

Unrelated to the PR, but since we are in LogHttpEventListener:

public override void Dispose()
{
base.Dispose();
_log.Flush();
if (!_processMessages.Wait(TimeSpan.FromSeconds(30)))
{
_stopProcessing.Cancel();
_processMessages.Wait();
}
_log.Dispose();
}

Will _processMessages actually ever finish without the cancellation? Shouldn't it be something like this instead?

 public override void Dispose() 
 { 
     base.Dispose(); 
     _log.Flush(); 
     _stopProcessing.Cancel(); 
     
     // Try to wait for the task to finish before disposing
      _processMessages.Wait(TimeSpan.FromSeconds(30));

     _log.Dispose(); 
 } 

@ManickaP
Copy link
Member Author

Unrelated to the PR, but since we are in LogHttpEventListener:
...

Ha ha the Dispose is never called 🤦 And you're right, Wait on it's own would hang. I'll try to fix this.

@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-http

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP
Copy link
Member Author

Fudge, win docker copy is borked 😢

@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-http

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP ManickaP force-pushed the mapichov/stress_improvements branch from 84697ff to f4dfff7 Compare August 19, 2021 12:10
@ManickaP ManickaP force-pushed the mapichov/stress_improvements branch from f4dfff7 to 4801fd1 Compare August 19, 2021 12:11
@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-http

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP
Copy link
Member Author

/azp run runtime-libraries stress-ssl

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP ManickaP merged commit 1eed512 into dotnet:main Aug 19, 2021
@ManickaP ManickaP deleted the mapichov/stress_improvements branch August 19, 2021 15:00
@karelz karelz added this to the 7.0.0 milestone Aug 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants