Drop cache support for lpm because with cache we slower

This commit is contained in:
Pavel Odintsov 2014-12-02 00:26:08 +04:00
parent ab4e726d36
commit 84a9b86fb7
4 changed files with 3 additions and 23 deletions

@ -21,6 +21,9 @@ add_definitions(-DPF_RING)
# Our LPM library
add_library(libpatricia STATIC libpatricia/patricia.c)
# Our sFLOW plugin
add_library(sflow_plugin STATIC sflow_collector.cpp)
# Main tool
add_executable(fastnetmon fastnetmon.cpp)

@ -22,7 +22,6 @@
#include <netdb.h>
#include "libpatricia/patricia.h"
#include "lru_cache/lru_cache.h"
#include <ncurses.h>
@ -97,8 +96,6 @@ string redis_host = "127.0.0.1";
bool redis_enabled = false;
#endif
typedef LRUCache<uint32_t, bool> lpm_cache_t;
// Time consumed by reaclculation for all IPs
struct timeval calculation_thread_execution_time;
@ -106,9 +103,6 @@ struct timeval calculation_thread_execution_time;
// We need this as global variable because it's very important value for configuring data structures
unsigned int total_number_of_hosts_in_our_networks = 0;
// LPM cache
lpm_cache_t *lpm_cache = NULL;
#ifdef GEOIP
GeoIP * geo_ip = NULL;
#endif
@ -1625,8 +1619,6 @@ void init_logging() {
}
int main(int argc,char **argv) {
lpm_cache = new lpm_cache_t(16);
lookup_tree = New_Patricia(32);
whitelist_tree = New_Patricia(32);
@ -2045,21 +2037,6 @@ bool fast_patricia_lookup(patricia_tree_t *patricia_tree, prefix_t* prefix) {
return result;
}
// DONT USE THIS VERSION!!! USE fast_patricia_lookup instead because this version os so slow!
bool cached_patricia_lookup(patricia_tree_t *patricia_tree, prefix_t* prefix, lpm_cache_t* lpm_cache) {
bool* lpm_status;
lpm_status = lpm_cache->fetch_ptr(prefix->add.sin.s_addr);
if (lpm_status == NULL) {
bool resolved_status = fast_patricia_lookup(patricia_tree, prefix);
lpm_cache->insert(prefix->add.sin.s_addr, resolved_status);
return resolved_status;
} else {
return lpm_status;
}
}
/* Get traffic type: check it belongs to our IPs */
direction get_packet_direction(uint32_t src_ip, uint32_t dst_ip, unsigned long& subnet) {
direction packet_direction;