Skip to content

Commit

Permalink
ct sync optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Aug 18, 2023
1 parent c744297 commit 35cc625
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1790,19 +1790,21 @@ func dpCTMapChkUpdates() {
}
if C.bpf_map_lookup_elem(C.int(fd), unsafe.Pointer(&cti.PKey[0]), unsafe.Pointer(&tact)) != 0 {
tk.LogIt(tk.LogInfo, "[CT] ent not found %s\n", cti.Key())
delete(mh.dpEbpf.ctMap, cti.Key())
continue
}
ptact := (*C.struct_dp_ct_tact)(unsafe.Pointer(&cti.PVal[0]))
ret := C.llb_fetch_map_stats_cached(C.int(C.LL_DP_CT_STATS_MAP), C.uint(ptact.ca.cidx), C.int(0),
(unsafe.Pointer(&b)), unsafe.Pointer(&p))
if ret == 0 {
if cti.Packets != p+uint64(tact.ctd.pb.packets) {
cti.Bytes = b + uint64(tact.ctd.pb.bytes)
cti.Packets = p + uint64(tact.ctd.pb.packets)
cti.XSync = true
cti.NTs = tc
cti.LTs = tc
//delete(mh.dpEbpf.ctMap, cti.Key())
cti.Deleted++
cti.XSync = true
} else {
ptact := (*C.struct_dp_ct_tact)(unsafe.Pointer(&cti.PVal[0]))
ret := C.llb_fetch_map_stats_cached(C.int(C.LL_DP_CT_STATS_MAP), C.uint(ptact.ca.cidx), C.int(0),
(unsafe.Pointer(&b)), unsafe.Pointer(&p))
if ret == 0 {
if cti.Packets != p+uint64(tact.ctd.pb.packets) {
cti.Bytes = b + uint64(tact.ctd.pb.bytes)
cti.Packets = p + uint64(tact.ctd.pb.packets)
cti.XSync = true
cti.NTs = tc
cti.LTs = tc
}
}
}
}
Expand Down Expand Up @@ -1833,7 +1835,10 @@ func dpCTMapChkUpdates() {

if len(blkCti) > 1024 {
tk.LogIt(tk.LogDebug, "[CT] Block Add Sync - \n")
tc1 := time.Now()
mh.dp.DpXsyncRPC(DpSyncAdd, blkCti)
tc2 := time.Now()
tk.LogIt(tk.LogInfo, "[CT] Block Add Sync %d took %v- \n", len(blkCti), time.Duration(tc2.Sub(tc1)))
blkCti = nil
}

Expand All @@ -1845,8 +1850,11 @@ func dpCTMapChkUpdates() {
}

if len(blkCti) > 0 {
tc1 := time.Now()
tk.LogIt(tk.LogDebug, "[CT] Block Add Sync - \n")
mh.dp.DpXsyncRPC(DpSyncAdd, blkCti)
tc2 := time.Now()
tk.LogIt(tk.LogInfo, "[CT] Block Add Sync %d took %v- \n", len(blkCti), time.Duration(tc2.Sub(tc1)))
}

if len(blkDelCti) > 0 {
Expand Down

0 comments on commit 35cc625

Please sign in to comment.