Skip to content

Counting bytes in tcp read write#267

Merged
igor-egorov merged 5 commits intolibp2p:masterfrom
ErakhtinB:1641-fix-sending-wrong-bandwidth-data-to-telemetry
Sep 27, 2024
Merged

Counting bytes in tcp read write#267
igor-egorov merged 5 commits intolibp2p:masterfrom
ErakhtinB:1641-fix-sending-wrong-bandwidth-data-to-telemetry

Conversation

@ErakhtinB
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/transport/tcp/tcp_connection.cpp Outdated
void TcpConnection::readSome(BytesOut out,
size_t bytes,
TcpConnection::ReadCallbackFunc cb) {
bytes_read_.fetch_add(bytes);
Copy link
Copy Markdown
Contributor

@turuslan turuslan Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we count bytes we wanted to read/write (call), or actually read/written bytes (callback)?

Comment thread include/libp2p/transport/tcp/tcp_connection.hpp Outdated
@ErakhtinB ErakhtinB force-pushed the 1641-fix-sending-wrong-bandwidth-data-to-telemetry branch from 60b988d to 5e4f87b Compare September 23, 2024 01:20

namespace libp2p::transport {

class ByteCounter {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May name it BandwidthMetric

Copy link
Copy Markdown
Member

@igor-egorov igor-egorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comments before merge

@@ -0,0 +1,32 @@
#pragma once
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#pragma once
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

@@ -0,0 +1,26 @@
#include <libp2p/transport/tcp/bytes_counter.hpp>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header


ByteCounter() = default;

public:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised that there is no method to reset the counters. Well, that is another possible approach.

@ErakhtinB ErakhtinB force-pushed the 1641-fix-sending-wrong-bandwidth-data-to-telemetry branch from c06c40a to 9b96203 Compare September 27, 2024 06:33
@igor-egorov igor-egorov merged commit 66764ac into libp2p:master Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants