Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: third_party/grpc/src/core/statistics/census_log.h

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 #ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H
35 #define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H
36
37 #include <stddef.h>
38
39 /* Maximum record size, in bytes. */
40 #define CENSUS_LOG_2_MAX_RECORD_SIZE 14 /* 2^14 = 16KB */
41 #define CENSUS_LOG_MAX_RECORD_SIZE (1 << CENSUS_LOG_2_MAX_RECORD_SIZE)
42
43 /* Initialize the statistics logging subsystem with the given log size. A log
44 size of 0 will result in the smallest possible log for the platform
45 (approximately CENSUS_LOG_MAX_RECORD_SIZE * gpr_cpu_num_cores()). If
46 discard_old_records is non-zero, then new records will displace older ones
47 when the log is full. This function must be called before any other
48 census_log functions.
49 */
50 void census_log_initialize(size_t size_in_mb, int discard_old_records);
51
52 /* Shutdown the logging subsystem. Caller must ensure that:
53 - no in progress or future call to any census_log functions
54 - no incomplete records
55 */
56 void census_log_shutdown(void);
57
58 /* Allocates and returns a 'size' bytes record and marks it in use. A
59 subsequent census_log_end_write() marks the record complete. The
60 'bytes_written' census_log_end_write() argument must be <=
61 'size'. Returns NULL if out-of-space AND:
62 - log is configured to keep old records OR
63 - all blocks are pinned by incomplete records.
64 */
65 void *census_log_start_write(size_t size);
66
67 void census_log_end_write(void *record, size_t bytes_written);
68
69 /* census_log_read_next() iterates over blocks with data and for each block
70 returns a pointer to the first unread byte. The number of bytes that can be
71 read are returned in 'bytes_available'. Reader is expected to read all
72 available data. Reading the data consumes it i.e. it cannot be read again.
73 census_log_read_next() returns NULL if the end is reached i.e last block
74 is read. census_log_init_reader() starts the iteration or aborts the
75 current iteration.
76 */
77 void census_log_init_reader(void);
78 const void *census_log_read_next(size_t *bytes_available);
79
80 /* Returns estimated remaining space across all blocks, in bytes. If log is
81 configured to discard old records, returns total log space. Otherwise,
82 returns space available in empty blocks (partially filled blocks are
83 treated as full).
84 */
85 size_t census_log_remaining_space(void);
86
87 /* Returns the number of times gprc_stats_log_start_write() failed due to
88 out-of-space. */
89 int census_log_out_of_space_count(void);
90
91 #endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H */
OLDNEW
« no previous file with comments | « third_party/grpc/src/core/statistics/census_interface.h ('k') | third_party/grpc/src/core/statistics/census_log.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698