Various changes related to counting SSL handshake + transfer on server side. Also changes gettimeofday to clock_gettime with monotonic counter

这个提交包含在:
Henry Case 2019-08-01 14:58:55 +01:00
父节点 694bebfc54
当前提交 53b9dab155
共有 5 个文件被更改,包括 72 次插入43 次删除

查看文件

@ -9,7 +9,7 @@
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
In addition, as a special exception, the copyright holders give
permission to link the code of this work with the OpenSSL project's
"OpenSSL" library (or with modified versions of it that use the same
@ -27,7 +27,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
*/
#ifndef conn_h
@ -84,6 +84,7 @@ typedef struct Conn
{
Time time_connect_start; /* time connect() got called */
u_int num_calls_completed; /* # of calls that completed */
Time ssl_handshake_connect_start; /* time connect() got called */
}
basic; /* maintained by stat/stats_basic.c */

查看文件

@ -58,6 +58,8 @@
#ifdef HAVE_KEVENT
#include <sys/event.h>
#include <cstddef>
/*
* Older systems using kevent() always specify the time in
* milliseconds and do not have a flag to select a different scale.
@ -90,6 +92,9 @@
#define MIN_IP_PORT IPPORT_RESERVED
#define MAX_IP_PORT 65535
#define BITSPERLONG (8*sizeof (u_long))
#ifdef HAVE_SSL
#define SSL_DATA_CONN 0x01
#endif // HAVE_SSL
struct local_addr {
struct in_addr ip;
@ -1048,6 +1053,17 @@ core_init(void)
#ifdef HAVE_SSL
// Starts counting time after key has been generated on client side
static void after_keygen_handshake_time(const SSL *ssl, int type, int value) {
struct Conn *data = 0;
if (type == SSL_CB_HANDSHAKE_WRITTEN) {
data = SSL_get_ex_data(ssl, SSL_DATA_CONN);
if (data) {
data->basic.ssl_handshake_connect_start = timer_now();
}
}
}
int
core_ssl_connect(Conn * s)
{
@ -1062,6 +1078,9 @@ core_ssl_connect(Conn * s)
exit(-1);
}
SSL_set_info_callback(s->ssl, after_keygen_handshake_time);
SSL_set_ex_data(s->ssl, SSL_DATA_CONN, s);
ssl_err = SSL_connect(s->ssl);
if (ssl_err < 0) {
int reason = SSL_get_error(s->ssl, ssl_err);

查看文件

@ -9,7 +9,7 @@
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
In addition, as a special exception, the copyright holders give
permission to link the code of this work with the OpenSSL project's
"OpenSSL" library (or with modified versions of it that use the same
@ -27,7 +27,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
*/
@ -76,7 +76,7 @@ get_line (Call *c, char **bufp, size_t *buf_lenp)
buf_len -= to_copy;
if (s->line.iov_len + to_copy >= sizeof (s->line_buf))
{
fprintf (stderr,
if (DBG>0) fprintf (stderr,
"%s.get_line: truncating header from %lu to %lu bytes\n",
prog_name, (u_long) (s->line.iov_len + to_copy),
(u_long) sizeof (s->line_buf));
@ -194,7 +194,7 @@ parse_status_line (Call *c, char **bufp, size_t *buf_lenp)
done:
c->reply.header_bytes += *bufp - buf_start;
s->line.iov_len = 0;
s->line.iov_len = 0;
}
static void
@ -259,7 +259,7 @@ parse_headers (Call *c, char **bufp, size_t *buf_lenp)
event_signal (EV_CALL_RECV_HDR, (Object *) c, arg);
if (s->state >= S_CLOSING)
return;
s->line.iov_len = 0;
s->line.iov_len = 0;
}
c->reply.header_bytes += *bufp - buf_start;
}
@ -288,7 +288,7 @@ parse_footers (Call *c, char **bufp, size_t *buf_lenp)
event_signal (EV_CALL_RECV_FOOTER, (Object *) c, arg);
if (s->state >= S_CLOSING)
return;
s->line.iov_len = 0;
s->line.iov_len = 0;
}
c->reply.footer_bytes += *bufp - buf_start;
}

查看文件

@ -1,36 +1,36 @@
/*
* httperf -- a tool for measuring web server performance
* Copyright 2000-2007 Hewlett-Packard Company
*
*
* This file is part of httperf, a web server performance measurment tool.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*
* In addition, as a special exception, the copyright holders give permission
* to link the code of this work with the OpenSSL project's "OpenSSL" library
* (or with modified versions of it that use the same license as the "OpenSSL"
* (or with modified versions of it that use the same license as the "OpenSSL"
* library), and distribute linked combinations including the two. You must
* obey the GNU General Public License in all respects for all of the code
* used other than "OpenSSL". If you modify this file, you may extend this
* exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Basic statistics collector.
* Basic statistics collector.
*/
#include "config.h"
@ -52,7 +52,7 @@
#include <stats.h>
/*
* Increase this if it does not cover at least 50% of all response times.
* Increase this if it does not cover at least 50% of all response times.
*/
#define MAX_LIFETIME 100.0 /* max. conn. lifetime in seconds */
#define BIN_WIDTH 1e-3
@ -105,6 +105,7 @@ static struct {
u_int conn_lifetime_hist[NUM_BINS]; /* histogram of
* connection lifetimes */
Time ssl_handshake_connect_start; /* time connect() got called */
} basic;
static u_long num_active_conns;
@ -132,7 +133,7 @@ perf_sample(Event_Type et, Object * obj, Any_Type reg_arg, Any_Type call_arg)
++basic.num_reply_rates;
/*
* prepare for next sample interval:
* prepare for next sample interval:
*/
num_replies = 0;
}
@ -214,7 +215,9 @@ conn_connected(Event_Type et, Object * obj, Any_Type reg_arg,
Conn *s = (Conn *) obj;
assert(et == EV_CONN_CONNECTED && object_is_conn(s));
basic.conn_connect_sum += timer_now() - s->basic.time_connect_start;
Time t = timer_now();
basic.conn_connect_sum += t - s->basic.time_connect_start;
basic.ssl_handshake_connect_start += t - s->basic.ssl_handshake_connect_start;
++basic.num_connects;
}
@ -359,7 +362,8 @@ static void
dump(void)
{
Time conn_period = 0.0, call_period = 0.0;
Time conn_time = 0.0, resp_time = 0.0, xfer_time = 0.0;
Time conn_time = 0.0, resp_time = 0.0, xfer_time = 0.0,
ssl_hs_time = 0.0;
Time call_size = 0.0, hdr_size = 0.0, reply_size =
0.0, footer_size = 0.0;
Time lifetime_avg = 0.0, lifetime_stddev =
@ -423,14 +427,20 @@ dump(void)
1e3 * lifetime_avg,
1e3 * basic.conn_lifetime_max, 1e3 * lifetime_median,
1e3 * lifetime_stddev);
if (basic.num_connects > 0)
if (basic.num_connects > 0) {
conn_time = basic.conn_connect_sum / basic.num_connects;
}
printf("Connection time [ms]: connect %.1f\n", 1e3 * conn_time);
printf("Connection length [replies/conn]: %.3f\n",
basic.num_lifetimes > 0
? total_replies / (double) basic.num_lifetimes : 0.0);
putchar('\n');
ssl_hs_time = basic.ssl_handshake_connect_start / basic.num_connects;
printf("SSL handshake time [ms]: %.3f\n", 1e3 * ssl_hs_time);
putchar('\n');
if (basic.num_sent > 0)
call_period = delta / basic.num_sent;
printf("Request rate: %.1f req/s (%.1f ms/req)\n",

查看文件

@ -1,32 +1,32 @@
/*
* Copyright (C) 2007 Ted Bullock <tbullock@comlore.com>
* Copyright (C) 2000 Hewlett-Packard Company
*
*
* This file is part of httperf, a web server performance measurment tool.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*
* In addition, as a special exception, the copyright holders give permission
* to link the code of this work with the OpenSSL project's "OpenSSL" library
* (or with modified versions of it that use the same license as the "OpenSSL"
* (or with modified versions of it that use the same license as the "OpenSSL"
* library), and distribute linked combinations including the two. You must
* obey the GNU General Public License in all respects for all of the code
* used other than "OpenSSL". If you modify this file, you may extend this
* exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
@ -52,26 +52,26 @@ struct Timer {
bool has_expired;
/*
* Callback function called when timer expires (timeout)
* Callback function called when timer expires (timeout)
*/
void (*timeout_callback) (struct Timer * t, Any_Type arg);
/*
* Typically used as a void pointer to the data object being timed
* Typically used as a void pointer to the data object being timed
*/
Any_Type timer_subject;
};
/*
* inactive timers
* inactive timers
*/
static struct List *passive_timers = NULL;
/*
* active timers
* active timers
*/
static struct List *active_timers = NULL;
/*
* active timeoutless timers
* active timeoutless timers
*/
static struct List *persistent_timers = NULL;
@ -83,10 +83,9 @@ static struct List *persistent_timers = NULL;
Time
timer_now_forced(void)
{
struct timeval tv;
gettimeofday(&tv, 0);
return tv.tv_sec + tv.tv_usec * 1e-6;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec + (ts.tv_nsec * 1e-9);
}
/*
@ -178,7 +177,7 @@ timer_has_expired(Any_Type a)
struct Timer *t = a.vp;
/*
* Only expire currently processing timers
* Only expire currently processing timers
*/
if (t->has_expired == false) {
if (t->time_started + t->timeout_delay < timer_now()) {
@ -217,7 +216,7 @@ timer_tick(void)
}
/*
* Schedules a timer into the active_timer list. Usually the timer is
* Schedules a timer into the active_timer list. Usually the timer is
* requisitioned from the passive_timer list to avoid making extra calls
* to malloc, but will allocate memory for a new counter if there are no
* inactive timers available
@ -269,8 +268,8 @@ timer_cancel(struct Timer *t)
fprintf(stderr, "timer_cancel: t=%p\n", t);
/*
* A module MUST NOT call timer_cancel() for a timer that is currently
* being processed (whose timeout has expired).
* A module MUST NOT call timer_cancel() for a timer that is currently
* being processed (whose timeout has expired).
*/
t->has_expired = true;