[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 <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2017-09-05 22:55:05 +01:00
parent 4674df25ef
commit 7e673a6b67
5 changed files with 114 additions and 0 deletions
+6
View File
@@ -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 );
+13
View File
@@ -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,