Skip to content

Commit

Permalink
packet drop issue resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
amarsri28 committed Nov 6, 2023
1 parent 4c03c9b commit f474f34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions core/modules/measure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ void Measure::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
uint64_t now_ns = tsc_to_ns(rdtsc());
size_t offset = offset_;

mcslock_node_t mynode;
mcs_lock(&lock_, &mynode);

pkt_cnt_ += batch->cnt();

int cnt = batch->cnt();
Expand All @@ -132,21 +129,20 @@ void Measure::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {

bytes_cnt_ += batch->pkts()[i]->total_len();

rtt_hist_.Insert(diff);
rtt_hist_.AtomicInsert(diff);
if (rand_.GetRealNonzero() <= jitter_sample_prob_) {
if (unlikely(!last_rtt_ns_)) {
last_rtt_ns_ = diff;
continue;
}
uint64_t jitter = absdiff(diff, last_rtt_ns_);
jitter_hist_.Insert(jitter);
int64_t jitter = diff - last_rtt_ns_;
jitter = jitter * ((jitter>0) - (jitter<0));
jitter_hist_.AtomicInsert(jitter);
last_rtt_ns_ = diff;
}
}
}

mcs_unlock(&lock_, &mynode);

RunNextModule(ctx, batch);
}

Expand Down
12 changes: 4 additions & 8 deletions core/modules/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "../utils/histogram.h"
#include "../utils/mcslock.h"
#include "../utils/random.h"

#include <atomic>
class Measure final : public Module {
public:
Measure(uint64_t ns_per_bucket = 1, uint64_t max_ns = 0)
Expand Down Expand Up @@ -69,22 +69,18 @@ class Measure final : public Module {
static const uint64_t kDefaultNsPerBucket = 100;
static const uint64_t kDefaultMaxNs = 100'000'000; // 100 ms
static constexpr double kDefaultIpDvSampleProb = 0.05;

void Clear();

Histogram<uint64_t> rtt_hist_;
Histogram<uint64_t> jitter_hist_;

Random rand_;
double jitter_sample_prob_;
uint64_t last_rtt_ns_;

std::atomic<std::uint64_t> last_rtt_ns_;
size_t offset_; // in bytes
int attr_id_;

uint64_t pkt_cnt_;
uint64_t bytes_cnt_;

std::atomic<std::uint64_t> pkt_cnt_;
std::atomic<std::uint64_t> bytes_cnt_;
mcslock lock_;
};

Expand Down

0 comments on commit f474f34

Please sign in to comment.