|
|
d1681e |
From d41cb3f53614dcf514d96717b5bde67b8d4c1335 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
|
|
|
d1681e |
Date: Mon, 12 Feb 2018 17:58:48 +0530
|
|
|
d1681e |
Subject: [PATCH 152/180] glusterfind: Speed up gfid lookup 100x by using an
|
|
|
d1681e |
SQL index
|
|
|
d1681e |
MIME-Version: 1.0
|
|
|
d1681e |
Content-Type: text/plain; charset=UTF-8
|
|
|
d1681e |
Content-Transfer-Encoding: 8bit
|
|
|
d1681e |
|
|
|
d1681e |
Fixes #1529883.
|
|
|
d1681e |
|
|
|
d1681e |
This fixes some bits of `glusterfind`'s horrible performance,
|
|
|
d1681e |
making it 100x faster.
|
|
|
d1681e |
|
|
|
d1681e |
Until now, glusterfind was, for each line in each CHANGELOG.* file,
|
|
|
d1681e |
linearly reading the entire contents of the sqlite database in
|
|
|
d1681e |
4096-bytes-sized pread64() syscalls when executing the
|
|
|
d1681e |
|
|
|
d1681e |
SELECT COUNT(1) FROM %s WHERE 1=1 AND gfid = ?
|
|
|
d1681e |
|
|
|
d1681e |
query through the code path:
|
|
|
d1681e |
|
|
|
d1681e |
get_changes()
|
|
|
d1681e |
parse_changelog_to_db()
|
|
|
d1681e |
when_data_meta()
|
|
|
d1681e |
gfidpath_exists()
|
|
|
d1681e |
_exists()
|
|
|
d1681e |
|
|
|
d1681e |
In a quick benchmark on my laptop, doing one such `SELECT` query
|
|
|
d1681e |
took ~75ms on a 10MB-sized sqlite DB, while doing the same query
|
|
|
d1681e |
with an index took < 1ms.
|
|
|
d1681e |
|
|
|
d1681e |
mainline:
|
|
|
d1681e |
> BUG: 1529883
|
|
|
d1681e |
> Reviewed-on: https://review.gluster.org/19114
|
|
|
d1681e |
> Reviewed-by: Aravinda VK <avishwan@redhat.com>
|
|
|
d1681e |
> Signed-off-by: Niklas Hambüchen <mail@nh2.me>
|
|
|
d1681e |
(cherry picked from commit 14dbd5da1cae64e6d4d2c69966e19844d090ce98)
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: I8e7fe60f1f45a06c102f56b54d2ead9e0377794e
|
|
|
d1681e |
Signed-off-by: Niklas Hambüchen <mail@nh2.me>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/130064
|
|
|
d1681e |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d1681e |
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
tools/glusterfind/src/changelogdata.py | 5 +++++
|
|
|
d1681e |
1 file changed, 5 insertions(+)
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/tools/glusterfind/src/changelogdata.py b/tools/glusterfind/src/changelogdata.py
|
|
|
d1681e |
index 3140d94..641593c 100644
|
|
|
d1681e |
--- a/tools/glusterfind/src/changelogdata.py
|
|
|
d1681e |
+++ b/tools/glusterfind/src/changelogdata.py
|
|
|
d1681e |
@@ -112,6 +112,11 @@ class ChangelogData(object):
|
|
|
d1681e |
"""
|
|
|
d1681e |
self.cursor.execute(create_table)
|
|
|
d1681e |
|
|
|
d1681e |
+ create_index = """
|
|
|
d1681e |
+ CREATE INDEX gfid_index ON gfidpath(gfid);
|
|
|
d1681e |
+ """
|
|
|
d1681e |
+ self.cursor.execute(create_index)
|
|
|
d1681e |
+
|
|
|
d1681e |
def _create_table_inodegfid(self):
|
|
|
d1681e |
drop_table = "DROP TABLE IF EXISTS inodegfid"
|
|
|
d1681e |
self.cursor.execute(drop_table)
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|