Classes | Typedefs | Functions | Variables
low_level_ping_pong.cc File Reference
#include <errno.h>
#include <netinet/ip.h>
#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "test/core/util/cmdline.h"
#include "test/core/util/histogram.h"
Include dependency graph for low_level_ping_pong.cc:

Go to the source code of this file.

Classes

struct  fd_pair
 
struct  test_strategy
 
struct  thread_args
 

Typedefs

typedef struct fd_pair fd_pair
 
typedef struct test_strategy test_strategy
 
typedef struct thread_args thread_args
 

Functions

static int accept_server (int listen_fd)
 
static int blocking_read_bytes (thread_args *args, char *buf)
 
static int blocking_write_bytes (struct thread_args *args, char *buf)
 
static void client_thread (thread_args *args)
 
static int connect_client (struct sockaddr *addr, socklen_t len)
 
static int create_listening_socket (struct sockaddr *port, socklen_t len)
 
int create_socket (const char *socket_type, fd_pair *client_fds, fd_pair *server_fds)
 
static int create_sockets_pipe (fd_pair *client_fds, fd_pair *server_fds)
 
static int create_sockets_socketpair (fd_pair *client_fds, fd_pair *server_fds)
 
static int create_sockets_tcp (fd_pair *client_fds, fd_pair *server_fds)
 
static int do_nothing (thread_args *)
 
int main (int argc, char **argv)
 
static double now (void)
 
static int poll_read_bytes (int fd, char *buf, size_t read_size, int spin)
 
static int poll_read_bytes_blocking (struct thread_args *args, char *buf)
 
static int poll_read_bytes_spin (struct thread_args *args, char *buf)
 
static void print_histogram (grpc_histogram *histogram)
 
void print_usage (char *argv0)
 
static int read_bytes (int fd, char *buf, size_t read_size, int spin)
 
static int run_all_benchmarks (size_t msg_size)
 
static int run_benchmark (const char *socket_type, thread_args *client_args, thread_args *server_args)
 
static void server_thread (thread_args *args)
 
static void server_thread_wrap (void *arg)
 
static int set_socket_nonblocking (thread_args *args)
 
static int spin_read_bytes (thread_args *args, char *buf)
 

Variables

static const char * read_strategy_usage
 
static const char * socket_type_usage
 
static const char * socket_types [] = {"tcp", "socketpair", "pipe"}
 
static test_strategy test_strategies []
 

Typedef Documentation

◆ fd_pair

typedef struct fd_pair fd_pair

◆ test_strategy

typedef struct test_strategy test_strategy

◆ thread_args

typedef struct thread_args thread_args

Function Documentation

◆ accept_server()

static int accept_server ( int  listen_fd)
static

Definition at line 408 of file low_level_ping_pong.cc.

◆ blocking_read_bytes()

static int blocking_read_bytes ( thread_args args,
char *  buf 
)
static

Definition at line 93 of file low_level_ping_pong.cc.

◆ blocking_write_bytes()

static int blocking_write_bytes ( struct thread_args args,
char *  buf 
)
static

Definition at line 191 of file low_level_ping_pong.cc.

◆ client_thread()

static void client_thread ( thread_args args)
static

Definition at line 294 of file low_level_ping_pong.cc.

◆ connect_client()

static int connect_client ( struct sockaddr *  addr,
socklen_t  len 
)
static

Definition at line 374 of file low_level_ping_pong.cc.

◆ create_listening_socket()

static int create_listening_socket ( struct sockaddr *  port,
socklen_t  len 
)
static

Definition at line 330 of file low_level_ping_pong.cc.

◆ create_socket()

int create_socket ( const char *  socket_type,
fd_pair client_fds,
fd_pair server_fds 
)

Definition at line 560 of file low_level_ping_pong.cc.

◆ create_sockets_pipe()

static int create_sockets_pipe ( fd_pair client_fds,
fd_pair server_fds 
)
static

Definition at line 481 of file low_level_ping_pong.cc.

◆ create_sockets_socketpair()

static int create_sockets_socketpair ( fd_pair client_fds,
fd_pair server_fds 
)
static

Definition at line 467 of file low_level_ping_pong.cc.

◆ create_sockets_tcp()

static int create_sockets_tcp ( fd_pair client_fds,
fd_pair server_fds 
)
static

Definition at line 417 of file low_level_ping_pong.cc.

◆ do_nothing()

static int do_nothing ( thread_args )
static

Definition at line 230 of file low_level_ping_pong.cc.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 628 of file low_level_ping_pong.cc.

◆ now()

static double now ( void  )
static

Definition at line 289 of file low_level_ping_pong.cc.

◆ poll_read_bytes()

static int poll_read_bytes ( int  fd,
char *  buf,
size_t  read_size,
int  spin 
)
static

Definition at line 102 of file low_level_ping_pong.cc.

◆ poll_read_bytes_blocking()

static int poll_read_bytes_blocking ( struct thread_args args,
char *  buf 
)
static

Definition at line 135 of file low_level_ping_pong.cc.

◆ poll_read_bytes_spin()

static int poll_read_bytes_spin ( struct thread_args args,
char *  buf 
)
static

Definition at line 139 of file low_level_ping_pong.cc.

◆ print_histogram()

static void print_histogram ( grpc_histogram histogram)
static

Definition at line 279 of file low_level_ping_pong.cc.

◆ print_usage()

void print_usage ( char *  argv0)

Definition at line 521 of file low_level_ping_pong.cc.

◆ read_bytes()

static int read_bytes ( int  fd,
char *  buf,
size_t  read_size,
int  spin 
)
static

Definition at line 71 of file low_level_ping_pong.cc.

◆ run_all_benchmarks()

static int run_all_benchmarks ( size_t  msg_size)
static

Definition at line 596 of file low_level_ping_pong.cc.

◆ run_benchmark()

static int run_benchmark ( const char *  socket_type,
thread_args client_args,
thread_args server_args 
)
static

Definition at line 576 of file low_level_ping_pong.cc.

◆ server_thread()

static void server_thread ( thread_args args)
static

Definition at line 255 of file low_level_ping_pong.cc.

◆ server_thread_wrap()

static void server_thread_wrap ( void *  arg)
static

Definition at line 274 of file low_level_ping_pong.cc.

◆ set_socket_nonblocking()

static int set_socket_nonblocking ( thread_args args)
static

Definition at line 218 of file low_level_ping_pong.cc.

◆ spin_read_bytes()

static int spin_read_bytes ( thread_args args,
char *  buf 
)
static

Definition at line 97 of file low_level_ping_pong.cc.

Variable Documentation

◆ read_strategy_usage

const char* read_strategy_usage
static
Initial value:
=
"Strategy for doing reads, which is one of:\n"
" blocking: blocking read calls\n"
" same_thread_poll: poll() call on same thread \n"
" spin_read: spinning non-blocking read() calls \n"
" spin_poll: spinning 0 timeout poll() calls \n"
""

Definition at line 501 of file low_level_ping_pong.cc.

◆ socket_type_usage

const char* socket_type_usage
static
Initial value:
=
"Type of socket used, one of:\n"
" tcp: fds are endpoints of a TCP connection\n"
" socketpair: fds come from socketpair()\n"
" pipe: fds come from pipe()\n"

Definition at line 515 of file low_level_ping_pong.cc.

◆ socket_types

const char* socket_types[] = {"tcp", "socketpair", "pipe"}
static

Definition at line 558 of file low_level_ping_pong.cc.

◆ test_strategies

test_strategy test_strategies[]
static
Initial value:

Definition at line 548 of file low_level_ping_pong.cc.

poll_read_bytes_spin
static int poll_read_bytes_spin(struct thread_args *args, char *buf)
Definition: low_level_ping_pong.cc:139
set_socket_nonblocking
static int set_socket_nonblocking(thread_args *args)
Definition: low_level_ping_pong.cc:218
spin_read_bytes
static int spin_read_bytes(thread_args *args, char *buf)
Definition: low_level_ping_pong.cc:97
blocking_read_bytes
static int blocking_read_bytes(thread_args *args, char *buf)
Definition: low_level_ping_pong.cc:93
poll_read_bytes_blocking
static int poll_read_bytes_blocking(struct thread_args *args, char *buf)
Definition: low_level_ping_pong.cc:135
do_nothing
static int do_nothing(thread_args *)
Definition: low_level_ping_pong.cc:230


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:22