Skip to content

Response checksum validation: std::stringstream per body chunk in WriteData serialises IO threads when the global locale is set #3963

Done

Description

@phoebusm

Describe the bug

With response checksum validation on (ResponseChecksumValidation::WHEN_SUPPORTED, default), CurlHttpClient's write callback builds every candidate header name with a std::stringstream. It does this for each chunk curl delivers.

src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp:

for (const auto& hashIterator : context->m_request->GetResponseValidationHashes())
{
  std::stringstream headerStr;
  headerStr<<"x-amz-checksum-"<<hashIterator.first;
  if(context->m_response->HasHeader(headerStr.str().c_str()))
  {
    hashIterator.second->Update(reinterpret_cast<unsigned char*>(ptr), sizeToWrite);
    break;
  }
}

std::stringstream could be expensive as it could take a process-wide lock, if std::locale is set globally, i.e.

std::locale locale{std::locale::classic(), new std::num_put<char>()};
(void)std::locale::global(locale);

According to flamegrpah, libstdc++ locks a process-wide mutex on every std::stringstream construction. The mutex contention brings performance degradation, especially when the checksum doesn't exist in the header

Image

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

No performance degradation if checksum validation is ON but no checksum is included in the header

Current Behavior

The mutex contention brings performance degradation, especially when the checksum doesn't exist in the header
(flamegraph upload pending as it is blocked by my company infosec policy)

Reproduction Steps

Set global locale and have checksum validation ON, then send getobject requests to an endpoint which doesn't reply checksum

Possible Solution

Just switch from std::stringstream to std::string should be suffice, as in https://github.com/man-group/ArcticDB/pull/3488/changes#diff-6f05d69d8029eaf8095dcfefe786418a7edc52daf510e5baee53680638f6316a

Additional Information/Context

No response

AWS CPP SDK version used

1.11.820

Compiler and Version used

gcc 11.4

Operating System and version

Ubuntu 22.04

Activity

  1. added
    bug
    needs-triage
    on Oct 21, 2026
  2. removed
    needs-triage
    on Oct 28, 2026
  3. sbiscigl commented on Oct 28, 2026

    @sbiscigl
    Collaborator

    merged to main, and will be released today under 1.11.919, give it a shot and let me know if you have any questions

  4. added
    response-requested
    on Oct 28, 2026
  5. phoebusm commented on Nov 5, 2026

    @phoebusm
    Author

    Thank you!

  6. removed
    response-requested
    on Nov 6, 2026
  7. github-actions commented on Nov 25, 2026

    @github-actions

    This issue is now closed. Comments on closed issues are hard for our team to see.
    If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions