diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-08-26 15:17:33 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-08-26 15:17:33 +0400 |
commit | e9606fd020e0b25be7ed9fade46a90a6454f3e3d (patch) | |
tree | 558955ed3b9f4d21329cf0e3733a5ec237866647 | |
parent | 52eacd589704ae63a3794a1ed111de06add196f3 (diff) | |
download | rspamd-e9606fd020e0b25be7ed9fade46a90a6454f3e3d.tar.gz rspamd-e9606fd020e0b25be7ed9fade46a90a6454f3e3d.zip |
* Change symbols planner sort logic to take into consideration not frequenses of symbols but their percent in total number
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/symbols_cache.c | 22 |
2 files changed, 28 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b78780bb3..dbc49de28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -524,3 +524,13 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory /var/run/rspamd/)") INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} /var/run/rspamd/)") ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + +# CPack section +SET(CPACK_DEBIAN_PACKAGE_DEPENDS libevent1 libgmime-2.0-2a) +SET(CPACK_PACKAGE_CONTACT "vsevolod@highsecure.ru") +SET(CPACK_PACKAGE_NAME rspamd) +SET(CPACK_SOURCE_IGNORE_FILES "\\\\.swp$" "/\\\\.hg/") +SET(CPACK_PACKAGE_VERSION_MAJOR ${RSPAMD_VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${RSPAMD_VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${RSPAMD_VERSION_PATCH}) +INCLUDE(CPack) diff --git a/src/symbols_cache.c b/src/symbols_cache.c index 8ee23b782..d1aec71de 100644 --- a/src/symbols_cache.c +++ b/src/symbols_cache.c @@ -31,7 +31,7 @@ #include "cfg_file.h" #define WEIGHT_MULT 2.0 -#define FREQUENCY_MULT 1.0 +#define FREQUENCY_MULT 100.0 #define TIME_MULT -1.0 /* After which number of messages try to resort cache */ @@ -42,6 +42,8 @@ #define MIN_CACHE 17 +uint64_t total_frequency; + int cache_cmp (const void *p1, const void *p2) { @@ -55,12 +57,17 @@ cache_logic_cmp (const void *p1, const void *p2) { const struct cache_item *i1 = p1, *i2 = p2; double w1, w2; - + int f1 = 0, f2 = 0; + + if (total_frequency > 0) { + f1 = i1->s->frequency / total_frequency; + f2 = i2->s->frequency / total_frequency; + } w1 = abs (i1->s->weight) * WEIGHT_MULT + - i1->s->frequency * FREQUENCY_MULT + + f1 * FREQUENCY_MULT + i1->s->avg_time * TIME_MULT; w2 = abs (i2->s->weight) * WEIGHT_MULT + - i2->s->frequency * FREQUENCY_MULT + + f2 * FREQUENCY_MULT + i2->s->avg_time * TIME_MULT; return (int)w2 - w1; @@ -105,6 +112,13 @@ get_mem_cksum (struct symbols_cache *cache) static void post_cache_init (struct symbols_cache *cache) { + int i; + + total_frequency = 0; + for (i = 0; i < cache->used_items; i ++) { + total_frequency += cache->items[i].s->frequency; + } + qsort (cache->items, cache->used_items, sizeof (struct cache_item), cache_logic_cmp); } |