1818#include < aws/core/Aws.h>
1919#include < aws/core/auth/AWSCredentials.h>
2020#include < aws/core/client/ClientConfiguration.h>
21+ #include < aws/core/client/DefaultRetryStrategy.h>
2122#include < aws/core/http/HttpClient.h>
2223#include < aws/core/http/HttpClientFactory.h>
2324#include < aws/core/http/HttpRequest.h>
@@ -183,12 +184,16 @@ makeS3Client(const ClientConfig & cfg, std::shared_ptr<Aws::Utils::Threading::Ex
183184 s3Config.useVirtualAddressing = false ;
184185 s3Config.payloadSigningPolicy = Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never;
185186 s3Config.executor = std::move (executor);
187+ // The bench measures single-attempt latency. With retries enabled the SDK
188+ // would re-read slot.body on retry, which conflicts with the slot's reuse
189+ // across iterations and would muddy the latency distribution.
190+ s3Config.retryStrategy = std::make_shared<Aws::Client::DefaultRetryStrategy>(0L , 0L );
186191
187192 return std::make_unique<Aws::S3 ::S3Client>(
188193 creds, std::make_shared<CachingS3EndpointProvider>(cfg.endpointUrl + " /" + cfg.bucket ), s3Config);
189194}
190195
191- static void printJson (std::vector<uint64_t > & latNs, const ClientConfig & cfg)
196+ static void printJson (std::vector<uint64_t > & latNs, const ClientConfig & cfg, uint32_t failedSessions )
192197{
193198 uint64_t total = latNs.size ();
194199 double durationS = static_cast <double >(cfg.durationNs ) / 1e9 ;
@@ -206,6 +211,7 @@ static void printJson(std::vector<uint64_t> & latNs, const ClientConfig & cfg)
206211 printf (" \" duration_s\" : %.3f,\n " , durationS);
207212 printf (" \" total\" : %lu,\n " , total);
208213 printf (" \" rps\" : %.1f,\n " , opsPerSec);
214+ printf (" \" errors\" : %u,\n " , failedSessions);
209215 printLatencyUs (latNs);
210216 printCounters ();
211217 printf (" }\n " );
@@ -463,6 +469,12 @@ class FiberHttpClientFactory final : public PocoHttpClientFactory
463469
464470/* *
465471 * FiberExecutor - runs SDK async tasks as fibers instead of OS threads.
472+ *
473+ * Note: SubmitToThread is unbounded -- FiberScheduler::run always succeeds, so
474+ * unlike PooledThreadExecutor (which blocks when the pool saturates) this
475+ * executor offers no backpressure. The s3-perf bench is bounded externally by
476+ * numJobs * ioDepth, so this is harmless here. Code copying this class into
477+ * production should add a bound (counting semaphore, slot accounting, etc.).
466478 */
467479class FiberExecutor final : public Aws::Utils::Threading::Executor
468480{
@@ -518,6 +530,8 @@ class S3Bench
518530
519531 std::vector<uint64_t > collectLatencies ();
520532
533+ uint32_t failedSessions () const ;
534+
521535private:
522536 struct Slot
523537 {
@@ -531,6 +545,7 @@ class S3Bench
531545 {
532546 std::thread thread;
533547 std::vector<uint64_t > latencies;
548+ bool failed = false ;
534549 };
535550
536551 void submit (Slot & slot, uint32_t & count);
@@ -580,6 +595,19 @@ std::vector<uint64_t> S3Bench::collectLatencies()
580595 return all;
581596}
582597
598+ uint32_t S3Bench::failedSessions () const
599+ {
600+ uint32_t count = 0 ;
601+ for (const Session & session : sessions)
602+ {
603+ if (session.failed )
604+ {
605+ count++;
606+ }
607+ }
608+ return count;
609+ }
610+
583611void S3Bench::submit (Slot & slot, uint32_t & count)
584612{
585613 bool doPut;
@@ -664,7 +692,12 @@ void S3Bench::runSession(Session * session)
664692
665693 if (slots[head].error )
666694 {
695+ // Fail-fast: a single S3 error terminates the session. With a misconfigured
696+ // endpoint or a transient failure every session exits after one bad outcome,
697+ // and the run produces no useful latency data. failedSessions exposes the
698+ // count so the caller can warn.
667699 LOG_ERROR (" S3 request failed: {}" , slots[head].error ->GetMessage ());
700+ session->failed = true ;
668701 head = (head + 1 ) % cfg.ioDepth ;
669702 break ;
670703 }
@@ -802,8 +835,14 @@ int main(int argc, char ** argv)
802835 LOG_INFO (" stopping benchmark" );
803836 bench.stop ();
804837
838+ uint32_t failedSessions = bench.failedSessions ();
839+ if (failedSessions > 0 )
840+ {
841+ LOG_WARN (" {}/{} sessions exited early due to S3 errors" , failedSessions, cfg.numJobs );
842+ }
843+
805844 auto latencies = bench.collectLatencies ();
806- printJson (latencies, cfg);
845+ printJson (latencies, cfg, failedSessions );
807846
808847 s3.reset ();
809848 Aws::ShutdownAPI (sdkOptions);
0 commit comments