From: Vsevolod Stakhov Date: Wed, 17 Dec 2014 18:29:33 +0000 (+0000) Subject: Tune shingles settings. X-Git-Tag: 0.8.0~78^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=491f27d645695c3db05054d8674a212fc819dbff;p=rspamd.git Tune shingles settings. --- diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index 653fa5356..3775b9e16 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -25,7 +25,7 @@ #include "fstring.h" #include "siphash.h" -#define SHINGLES_WINDOW 10 +#define SHINGLES_WINDOW 3 static void rspamd_shingles_update_row (rspamd_fstring_t *in, struct siphash *h) @@ -84,6 +84,7 @@ rspamd_shingles_generate (GArray *input, g_checksum_reset (cksum); cur_key = out_key; out_key += 16; + memset (&h[i], 0, sizeof (h[0])); sip24_init (&h[i], &keys[i]); } @@ -96,15 +97,17 @@ rspamd_shingles_generate (GArray *input, rspamd_shingles_update_row (&g_array_index (input, rspamd_fstring_t, j), h); } + beg++; /* Now we need to create a new row here */ for (j = 0; j < RSPAMD_SHINGLE_SIZE; j ++) { guint64 val; - val = sip24_final (&h[i]); + val = sip24_final (&h[j]); /* Reinit siphash state */ - sip24_init (&h[i], &keys[i]); - g_array_append_val (hashes[i], val); + memset (&h[j], 0, sizeof (h[0])); + sip24_init (&h[j], &keys[j]); + g_array_append_val (hashes[j], val); } } } @@ -148,5 +151,5 @@ gdouble rspamd_shingles_compare (const struct rspamd_shingle *a, } } - return (gdouble)common / 84.0; + return (gdouble)common / (gdouble)RSPAMD_SHINGLE_SIZE; } diff --git a/src/libutil/shingles.h b/src/libutil/shingles.h index 39e9cf38d..61b3b24c3 100644 --- a/src/libutil/shingles.h +++ b/src/libutil/shingles.h @@ -26,7 +26,7 @@ #include "config.h" #include "mem_pool.h" -#define RSPAMD_SHINGLE_SIZE 84 +#define RSPAMD_SHINGLE_SIZE 23 struct rspamd_shingle { guint64 hashes[RSPAMD_SHINGLE_SIZE];