mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Expand hot cache map size to 32k entries (as Gates would say,
that should be enough for everyone). Add a "negative cache" element. When a "no match" item appears, it is mapped to CPU 4294967294. That's considered a safe magic number, because if you have that many CPUs in one box you are really going to surprise me. If an LPM lookup occurs, and still comes up as "no match" - then the item is cached with this sentinel value. If a hot cache hit returns the sentinal value, it returns NULL just like if no hit had occurred. This should eliminate the performance penalty that accompanies IP addresses blasting out as fast as they can, but not being in Shaped Devices.
This commit is contained in:
parent
8372786d46
commit
0e711dc09c
@ -99,6 +99,11 @@ static __always_inline struct ip_hash_info * setup_lookup_key_and_tc_cpu(
|
||||
&lookup_key->address
|
||||
);
|
||||
if (ip_info) {
|
||||
// Is it a negative hit?
|
||||
if (ip_info->cpu == NEGATIVE_HIT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// We got a cache hit, so return
|
||||
return ip_info;
|
||||
}
|
||||
@ -118,6 +123,19 @@ static __always_inline struct ip_hash_info * setup_lookup_key_and_tc_cpu(
|
||||
ip_info,
|
||||
BPF_NOEXIST
|
||||
);
|
||||
} else {
|
||||
// Store a negative result. This is designed to alleviate the pain
|
||||
// of repeatedly hitting queries for IPs that ARE NOT shaped.
|
||||
struct ip_hash_info negative_hit = {
|
||||
.cpu = NEGATIVE_HIT,
|
||||
.tc_handle = NEGATIVE_HIT
|
||||
};
|
||||
bpf_map_update_elem(
|
||||
&ip_to_cpu_and_tc_hotcache,
|
||||
&lookup_key->address,
|
||||
&negative_hit,
|
||||
BPF_NOEXIST
|
||||
);
|
||||
}
|
||||
#endif
|
||||
return ip_info;
|
||||
|
@ -16,4 +16,8 @@
|
||||
#define MAX_PACKETS MAX_FLOWS
|
||||
|
||||
// Hot Cache Size
|
||||
#define HOT_CACHE_SIZE 512
|
||||
#define HOT_CACHE_SIZE 32768
|
||||
|
||||
// Hot Cache Negative Hit Flag
|
||||
// If you have 4294967294 CPUs, I love you.
|
||||
#define NEGATIVE_HIT 4294967294
|
@ -13,4 +13,6 @@ rm -v /sys/fs/bpf/bifrost_vlan_map
|
||||
rm -v /sys/fs/bpf/heimdall
|
||||
rm -v /sys/fs/bpf/heimdall_config
|
||||
rm -v /sys/fs/bpf/heimdall_watching
|
||||
rm -v /sys/fs/bpf/flowbee
|
||||
rm -v /sys/fs/bpf/flowbee
|
||||
rm -v /sys/fs/bpf/ip_to_cpu_and_tc_hotcache
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user