From 7e673a6b67be1594e16a8cc5ab4a0d6c17799547 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 5 Sep 2017 22:55:05 +0100 Subject: [peerdist] Gather and report peer statistics during download Record and report the number of peers (calculated as the maximum number of peers discovered for a block's segment at the time that the block download is complete), and the percentage of blocks retrieved from peers rather than from the origin server. Signed-off-by: Michael Brown --- src/include/ipxe/peerdisc.h | 6 ++++++ src/include/ipxe/peermux.h | 13 +++++++++++++ 2 files changed, 19 insertions(+) (limited to 'src/include') diff --git a/src/include/ipxe/peerdisc.h b/src/include/ipxe/peerdisc.h index f08ccaae..45d592e7 100644 --- a/src/include/ipxe/peerdisc.h +++ b/src/include/ipxe/peerdisc.h @@ -109,6 +109,12 @@ peerdisc_init ( struct peerdisc_client *peerdisc, extern unsigned int peerdisc_timeout_secs; +extern void peerdisc_stat ( struct interface *intf, struct peerdisc_peer *peer, + struct list_head *peers ); +#define peerdisc_stat_TYPE( object_type ) \ + typeof ( void ( object_type, struct peerdisc_peer *peer, \ + struct list_head *peers ) ) + extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id, size_t len ); extern void peerdisc_close ( struct peerdisc_client *peerdisc ); diff --git a/src/include/ipxe/peermux.h b/src/include/ipxe/peermux.h index 44cbdb9d..54acbfec 100644 --- a/src/include/ipxe/peermux.h +++ b/src/include/ipxe/peermux.h @@ -41,6 +41,16 @@ struct peerdist_multiplexed_block { struct interface xfer; }; +/** PeerDist statistics */ +struct peerdist_statistics { + /** Maximum observed number of peers */ + unsigned int peers; + /** Number of blocks downloaded in total */ + unsigned int total; + /** Number of blocks downloaded from peers */ + unsigned int local; +}; + /** A PeerDist download multiplexer */ struct peerdist_multiplexer { /** Reference count */ @@ -65,6 +75,9 @@ struct peerdist_multiplexer { struct list_head idle; /** Block downloads */ struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS]; + + /** Statistics */ + struct peerdist_statistics stats; }; extern int peermux_filter ( struct interface *xfer, struct interface *info, -- cgit v1.2.3-55-g7522