Merge pull request #167 from maxwell-demon/master

Fix census_log_tests on platforms with only one core.
pull/265/head
Alistair Veitch 10 years ago
commit 4d9f3d7b63
  1. 8
      src/core/statistics/census_tracing.h
  2. 6
      test/core/statistics/census_log_tests.c

@ -34,6 +34,10 @@
#ifndef __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_
#define __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Opaque structure for trace object */
typedef struct trace_obj trace_obj;
@ -56,4 +60,8 @@ void census_internal_unlock_trace_store(void);
/* Gets method tag name associated with the input trace object. */
const char* census_get_trace_method_name(const trace_obj* trace);
#ifdef __cplusplus
}
#endif
#endif /* __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_ */

@ -123,11 +123,11 @@ static void assert_log_empty(void) {
/* Given log size and record size, computes the minimum usable space. */
static gpr_int32 min_usable_space(size_t log_size, size_t record_size) {
gpr_int32 usable_space;
gpr_int32 num_blocks = log_size / CENSUS_LOG_MAX_RECORD_SIZE;
gpr_int32 num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE,
gpr_cpu_num_cores());
gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size;
/* In the worst case, all except one core-local block is full. */
gpr_int32 num_full_blocks = GPR_MAX(gpr_cpu_num_cores() - 2, 2);
GPR_ASSERT(num_blocks >= num_full_blocks);
gpr_int32 num_full_blocks = num_blocks - 1;
usable_space = (gpr_int32)log_size -
(num_full_blocks * CENSUS_LOG_MAX_RECORD_SIZE) -
((num_blocks - num_full_blocks) * waste_per_block);

Loading…
Cancel
Save