Merge pull request #13192 from vjpai/spp

Fix a data race in microbenchmark stats gathering
pull/13216/head
Vijay Pai 7 years ago committed by GitHub
commit 8afaf61fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      test/core/util/passthru_endpoint.c
  2. 4
      test/core/util/passthru_endpoint.h
  3. 4
      test/cpp/microbenchmarks/fullstack_fixtures.h

@ -82,7 +82,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
half *m = other_half((half *)ep);
gpr_mu_lock(&m->parent->mu);
grpc_error *error = GRPC_ERROR_NONE;
m->parent->stats->num_writes++;
gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1);
if (m->parent->shutdown) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
} else if (m->on_read != NULL) {

@ -19,9 +19,11 @@
#ifndef MOCK_ENDPOINT_H
#define MOCK_ENDPOINT_H
#include <grpc/support/atm.h>
#include "src/core/lib/iomgr/endpoint.h"
typedef struct { int num_writes; } grpc_passthru_endpoint_stats;
typedef struct { gpr_atm num_writes; } grpc_passthru_endpoint_stats;
void grpc_passthru_endpoint_create(grpc_endpoint **client,
grpc_endpoint **server,

@ -25,6 +25,7 @@
#include <grpc++/security/server_credentials.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
extern "C" {
@ -259,7 +260,8 @@ class InProcessCHTTP2 : public EndpointPairFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
EndpointPairFixture::AddToLabel(out, state);
out << " writes/iter:"
<< (double)stats_.num_writes / (double)state.iterations();
<< static_cast<double>(gpr_atm_no_barrier_load(&stats_.num_writes)) /
static_cast<double>(state.iterations());
}
private:

Loading…
Cancel
Save