mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 18:36:52 +01:00
tun: Drop the staged timing metrics
This commit is contained in:
1 parent
51591b0cec
commit
5cbbba254e
5 files changed
+37
-148
No files matched your search
@@ -1,13 +1,10 @@
|
||||
package nebula
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rcrowley/go-metrics"
|
||||
"github.com/slackhq/nebula/config"
|
||||
"github.com/slackhq/nebula/noiseutil"
|
||||
)
|
||||
@@ -25,10 +22,6 @@ import (
|
||||
// Metrics are registered only for active pipelines. flow.{tx,rx}.batches counts reads handed to the ordered stage and
|
||||
// flow.{tx,rx}.inline those the reader handled itself (TX inline also counts oversized reads); their rates show
|
||||
// whether staging is used. flow.tx.gate_switches counts transmit switches between inline and fanout mode.
|
||||
// flow.stage.<stage>.q<queue>.busy_ns locates the limiting stage: tx_read, tx_encrypt, tx_send, rx_read, rx_decrypt or
|
||||
// rx_write. Take rates; 1e9 ns/s fills a serial stage. These are elapsed times that exclude read syscalls and
|
||||
// downstream waits; descheduling inflates them and worker times add up across the pool.
|
||||
// Inline work counts at the reader; small RX batches sent to the writer include decryption in writer time.
|
||||
|
||||
// stagedConfig is tun.staged. workers is per routine and direction; zero keeps processing inline.
|
||||
type stagedConfig struct {
|
||||
@@ -112,38 +105,17 @@ type flowPool struct {
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func newFlowPool(workers, queueLen int, busy metrics.Counter) *flowPool {
|
||||
func newFlowPool(workers, queueLen int) *flowPool {
|
||||
p := &flowPool{jobs: make(chan flowJob, queueLen)}
|
||||
for range workers {
|
||||
p.wg.Go(func() {
|
||||
nb := make([]byte, 12)
|
||||
for job := range p.jobs {
|
||||
// One pair of clock reads covers a run of jobs that are queued back to back
|
||||
t := time.Now()
|
||||
for job != nil {
|
||||
job.run(nb)
|
||||
job = p.next()
|
||||
}
|
||||
busy.Inc(int64(time.Since(t)))
|
||||
job.run(nb)
|
||||
}
|
||||
})
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// next returns the next queued job without waiting, or nil.
|
||||
func (p *flowPool) next() flowJob {
|
||||
select {
|
||||
case job := <-p.jobs:
|
||||
return job
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p *flowPool) close() { close(p.jobs); p.wg.Wait() }
|
||||
|
||||
// stageBusy is the busy time counter of one stage of routine q.
|
||||
func stageBusy(stage string, q int) metrics.Counter {
|
||||
return metrics.GetOrRegisterCounter(fmt.Sprintf("flow.stage.%s.q%d.busy_ns", stage, q), nil)
|
||||
}
|
||||
Reference in new issue
Block a user