Simon Lange wrote:
> i became aware that dbmail-imapd does consume pretty fast a lot of cpu
> time.
> e.g. i do connect via thunderbird to my account and all i do is quering
> a list of message in a folder it takes him up to 50% cputime (on a AMD
> AthlonXP2000+ 512MB).
This is a known issue. Apply the attached patch to mysql/dbmysql.c to
fix it.
> Also i came aware that imapd sporadic starts spamming the mysql database
> with queries. this increases the load enormous and the system becomes
> unusable. last time i metered imapd/mysql it took 262.000queries/sec
I wish I could ask you to get the logs for this, so that I could know
what causes this. (It was reported before). However, detailed logging
slows the system down about 10 times, and this is not yet resolved.
Yours, Mikhail Ramendik
--- mysql/dbmysql.c.orig 2004-06-03 16:41:55.000000000 +0400
+++ mysql/dbmysql.c 2004-10-23 16:10:31.000000000 +0400
@@ -1,6 +1,8 @@
/*
Copyright (C) 1999-2004 IC & S [EMAIL PROTECTED]
+ Modified 2004 by Mikhail Ramendik [EMAIL PROTECTED] (MR)
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
@@ -49,6 +51,11 @@
static MYSQL_RES *stored_res = NULL; /**< MySQL result set backup */
static MYSQL_ROW last_row; /**< MySQL result row */
+/* Additions by MR */
+
+static int res_changed = 1; /* result set changed */
+static unsigned last_row_number = 0; /* the number of the row in last_row */
+
/** database parameters */
db_param_t _db_params;
@@ -134,6 +141,7 @@
trace(TRACE_WARNING, "%s,%s: Trying to free result set "
"that is already NULL!", __FILE__, __func__);
res = NULL;
+ res_changed = 1; /*MR*/
}
@@ -154,9 +162,28 @@
return NULL;
}
- mysql_data_seek(res, row);
- last_row = mysql_fetch_row(res);
+ /*MR*/
+
+ if (res_changed)
+
+ {
+ mysql_data_seek(res, row);
+ last_row = mysql_fetch_row(res);
+ } else {
+ if (row == last_row_number+1)
+ last_row = mysql_fetch_row(res);
+ else if (row != last_row_number) {
+ mysql_data_seek(res, row);
+ last_row = mysql_fetch_row(res);
+ };
+ /* otherwise last_row is already loaded and does not need to change! MR*/
+ };
+ res_changed = 0;
+ last_row_number = row;
+
+ /*MR changes end here*/
+
if (last_row == NULL) {
trace(TRACE_WARNING, "%s,%s: row is NULL\n",
__FILE__, __func__);
@@ -238,6 +265,7 @@
}
res = mysql_store_result(&conn);
+ res_changed = 1; /*MR*/
return 0;
}
@@ -304,12 +332,14 @@
{
stored_res = res;
res = msgbuf_res;
+ res_changed = 1; /*MR*/
}
void db_store_msgbuf_result()
{
msgbuf_res = res;
res = stored_res;
+ res_changed = 1; /*MR*/
}
void *db_get_result_set()
@@ -320,4 +350,5 @@
void db_set_result_set(void *the_result_set)
{
res = (MYSQL_RES *) the_result_set;
+ res_changed = 1; /*MR*/
}