mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Improve performance significantly. We store if (and if: why) a certain domain was blocked for any requesting client and can immediately reply similarly if the same client requests the same domain again. This reduces the O(N^3) problem (number of queries * number of domains * number of clients) to a O(N^2) problem (domains * clients). Note that this state of the code still lacks a possibility to reset when entries in the database have changed. For this, we still have to send either SIGHUP (drawback: clears the cache) or define a new signal for it.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+21
-1
@@ -15,13 +15,33 @@
|
||||
|
||||
#define VEC_ALLOC_STEP 2u
|
||||
|
||||
/*
|
||||
typedef struct vector {
|
||||
unsigned int size;
|
||||
unsigned int capacity;
|
||||
bool *alloc;
|
||||
void **items;
|
||||
} vector;
|
||||
*/
|
||||
|
||||
typedef struct ucharvec {
|
||||
unsigned int size;
|
||||
unsigned int capacity;
|
||||
unsigned char *items;
|
||||
unsigned char (*get)(struct ucharvec *, unsigned int);
|
||||
void (*append)(struct ucharvec *, unsigned char);
|
||||
void (*set)(struct ucharvec *, unsigned int, unsigned char);
|
||||
void (*del)(struct ucharvec *, unsigned int);
|
||||
void (*free)(struct ucharvec *);
|
||||
} ucharvec;
|
||||
|
||||
ucharvec *new_ucharvec(unsigned int initial_size);
|
||||
void append_ucharvec(ucharvec *v, unsigned char item);
|
||||
void set_ucharvec(ucharvec *v, unsigned int index, unsigned char item);
|
||||
unsigned char get_ucharvec(ucharvec *v, unsigned int index) __attribute__((pure));
|
||||
void del_ucharvec(ucharvec *v, unsigned int index);
|
||||
void free_ucharvec(ucharvec *v);
|
||||
/*
|
||||
vector *vNew(void);
|
||||
unsigned int vSize(vector *v);
|
||||
void vAppend(vector *v, void *item, bool allocated);
|
||||
@@ -29,5 +49,5 @@ void vSet(vector *v, unsigned int index, void *item, bool allocated);
|
||||
void *vGet(vector *v, unsigned int index) __attribute__((pure));
|
||||
void vRemove(vector *v, unsigned int index);
|
||||
void vFree(vector *v);
|
||||
|
||||
*/
|
||||
#endif //VECTOR_H
|
||||
|
||||
Reference in New Issue
Block a user