[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:
@@ -270,6 +270,9 @@ static int peerblk_deliver ( struct peerdist_block *peerblk,
|
||||
*/
|
||||
static void peerblk_done ( struct peerdist_block *peerblk, int rc ) {
|
||||
struct digest_algorithm *digest = peerblk->digest;
|
||||
struct peerdisc_segment *segment = peerblk->discovery.segment;
|
||||
struct peerdisc_peer *head;
|
||||
struct peerdisc_peer *peer;
|
||||
uint8_t hash[digest->digestsize];
|
||||
unsigned long now = peerblk_timestamp();
|
||||
|
||||
@@ -296,6 +299,11 @@ static void peerblk_done ( struct peerdist_block *peerblk, int rc ) {
|
||||
profile_custom ( &peerblk_attempt_success_profiler,
|
||||
( now - peerblk->attempted ) );
|
||||
|
||||
/* Report peer statistics */
|
||||
head = list_entry ( &segment->peers, struct peerdisc_peer, list );
|
||||
peer = ( ( peerblk->peer == head ) ? NULL : peerblk->peer );
|
||||
peerdisc_stat ( &peerblk->xfer, peer, &segment->peers );
|
||||
|
||||
/* Close download */
|
||||
peerblk_close ( peerblk, 0 );
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user