-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix high CPU utilization regression on event streaming #3318
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,11 @@ namespace Aws | |
namespace Stream | ||
{ | ||
const char TAG[] = "ConcurrentStreamBuf"; | ||
|
||
const int ConcurrentStreamBuf::noData = ((((('n' << 8) | 'z') << 8) | 'm') << 8) | 'a'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is 'n' and 'm' evaluated ? I see that 'z' and 'a' states are treated now as same state when try lock can't be achieved or m_getArea is empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ConcurrentStreamBuf::noData is a magic variable with a value of 1634564718
We can't return -1 - it is already reserved for eof. |
||
|
||
ConcurrentStreamBuf::ConcurrentStreamBuf(size_t bufferLength) : | ||
m_putArea(bufferLength), // we access [0] of the put area below so we must initialize it. | ||
m_eofInput(false), | ||
m_eofOutput(false) | ||
m_putArea(bufferLength) // we access [0] of the put area below so we must initialize it. | ||
{ | ||
m_getArea.reserve(bufferLength); | ||
m_backbuf.reserve(bufferLength); | ||
|
@@ -163,7 +164,7 @@ namespace Aws | |
if (!lock.try_lock()) | ||
{ | ||
// don't block consumer, it will retry asking later | ||
return 'z'; // just returning some valid value other than EOF | ||
return noData; | ||
} | ||
|
||
if (m_eofInput && m_backbuf.empty()) | ||
|
@@ -187,10 +188,10 @@ namespace Aws | |
char* gbegin = reinterpret_cast<char*>(m_getArea.data()); | ||
setg(gbegin, gbegin, gbegin + m_getArea.size()); | ||
|
||
if (!m_getArea.empty()) | ||
if (!m_getArea.empty()) { | ||
return std::char_traits<char>::to_int_type(*gptr()); | ||
else | ||
return 'a'; // just returning some valid value other than EOF | ||
} | ||
return noData; | ||
} | ||
|
||
int ConcurrentStreamBuf::uflow() | ||
|
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 also extend this change to the smithy client else pending fixes will pile up
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'd prefer to have a completely different design of streaming for the smithy client.
also smithy client does not use for loop for retry logic.