aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2010-12-15 12:48:28 -0600
committerPeter Seebach <peter.seebach@windriver.com>2010-12-16 16:35:12 -0600
commit07e3c34553637ed8e62ccc1318c4fe91764a2017 (patch)
tree63c36e8870e10eea04a0d65e9d075f1f6d1c7c19
parent0eec00c99f7c7e25313caa97937a77383df8b0e8 (diff)
downloadpseudo-07e3c34553637ed8e62ccc1318c4fe91764a2017.tar.gz
pseudo-07e3c34553637ed8e62ccc1318c4fe91764a2017.tar.bz2
pseudo-07e3c34553637ed8e62ccc1318c4fe91764a2017.zip
Add sqlite call profiling
Add sqlite call profiling, this allows us to see the sqlite calls that are being made as the system runs, via the pseudo log. It was noted that by this profiling that a small change to pseudo.c, when a file was found, reduced the sqlite SELECT calls by about 1/3. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
-rw-r--r--ChangeLog.txt4
-rw-r--r--pseudo.c2
-rw-r--r--pseudo_db.c12
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 0c942e7..2bbd351 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2010-12-15:
+ * (mhatle) add sqlite call profiling, enable with NPROFILE
+ * (mhatle) as a result of profiling, optimize inode search
+
2010-12-14:
* (mhatle) restructure wrapfuncs.c
diff --git a/pseudo.c b/pseudo.c
index 350ad6b..2e2d56f 100644
--- a/pseudo.c
+++ b/pseudo.c
@@ -474,7 +474,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) {
/* search on original inode -- in case of mismatch */
by_ino = msg_header;
if (msg_header.ino != 0) {
- if (msg->pathlen && !pdb_find_file_exact(msg)) {
+ if (found_path && msg->pathlen && !pdb_find_file_exact(msg)) {
/* restore header contents */
by_ino = *msg;
*msg = msg_header;
diff --git a/pseudo_db.c b/pseudo_db.c
index 225dd37..5c62598 100644
--- a/pseudo_db.c
+++ b/pseudo_db.c
@@ -30,6 +30,15 @@
#include "pseudo_ipc.h"
#include "pseudo_db.h"
+/* #define NPROFILE */
+
+#ifdef NPROFILE
+void xProfile(void * pArg, const char * pQuery, sqlite3_uint64 pTimeTaken)
+{
+ pseudo_diag("profile: %lld %s\n", pTimeTaken, pQuery);
+}
+#endif
+
struct log_history {
int rc;
unsigned long fields;
@@ -401,6 +410,9 @@ get_db(sqlite3 **db) {
if (db == &file_db) {
dbfile = pseudo_localstatedir_path("files.db");
rc = sqlite3_open(dbfile, db);
+#ifdef NPROFILE
+ sqlite3_profile(*db, xProfile, NULL);
+#endif
free(dbfile);
} else {
dbfile = pseudo_localstatedir_path("logs.db");