Sphinx 3 vs Manticore: 性能基准测试

[更新] 更新的基准测试在 这里

最近,期待已久的 Sphinx 3 已经 发布 并在 3.0.2 中 更新 。它具备文档存储功能、A 索引、片段预索引,遗憾的是不再是开源软件(至少在 2018 年 3 月现在是这样)。

这些都是非常不错的功能,但你是否对它们对 Sphinx 3 性能的影响以及与 Manticore 性能的差异感兴趣?我们也是!

为了弄清楚这一点,我们进行了基准测试以测量:

基准测试基于以下内容:

  • luceneutil 生成索引和查询集的数据
  • lucene2manticore 将数据从 Lucene 转换为 Manticore Search / Sphinx 格式
  • stress-tester 进行基准测试
  • 服务器:8xIntel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz,64G RAM,HDD
  • 操作系统:Ubuntu 16.04.3 LTS,内核 4.8.0-45-generic

以下是结果:

ms_vs_s3_indexation

ms_vs_s3_throughputms_vs_s3_latency可以看出,在 所有测试场景中,Sphinx 3 的索引时间明显更高,性能也更差:无论是吞吐量还是延迟。我们倾向于相信这可能是由于某些编译问题(再次强调,Sphinx 3 不是开源的,因此我们无法重新编译)或某种一般性能泄漏,如果源代码可用的话,可以进行调试和修复。如果新功能使性能下降如此之多,那将是令人遗憾的。但无论如何,我们想警告所有 Manticore 和 Sphinx 的用户,如果你迁移到 Sphinx 3,可能会出现性能下降。

如果你在迁移到 Sphinx 3 或 Manticore 和 Sphinx 3 之间的比较中有不同的结果,请告诉我们,了解在什么情况下性能不会下降将是很好的。

如果你需要我们的帮助,请联系。


这是你可以重现基准测试的方法

请注意,下载和准备数据可能需要几个小时。

  1. 安装上述辅助工具并准备配置和停用词文件:
mkdir data
mkdir q

git clone http://github.com/mikemccand/luceneutil.git
git clone http://github.com/manticoresoftware/lucene2manticore
git clone http://github.com/Ivinco/stress-tester

cp lucene2manticore/*.conf ./
  1. 安装 Manticore SearchSphinx3 二进制文件。
  2. 获取并准备源数据
cd luceneutil
python src/python/setup.py -download
cd ../data/
xzcat enwiki-20120502-lines-1k.txt.lzma > lucene.tsv

将数据从 Lucene TSV 类似格式转换为可以与 Manticore Search 和 Sphinx 数据源一起使用的正确 TSV 格式:

cd ..
python lucene2manticore/lucene2tsv.py data/lucene.tsv --maxlen 2097152 > data/lc.tsv
head -n 100000 data/lc.tsv >  data/lc100k.tsv
head -n 300000 data/lc.tsv > data/lc300k.tsv
head -n 1000000 data/lc.tsv > data/lc1m.tsv
  1. 准备查询
python lucene2manticore/lucene2query.py --types simple data/wikimedium500.tasks > q/q-wiki500-simple.txt
python lucene2manticore/lucene2query.py --types ext2 data/wikimedium500.tasks > q/q-wiki500-ext2.txt
python lucene2manticore/lucene2query.py --types simple luceneutil/tasks/wikimedium.10M.datefacets.nostopwords.tasks > q/q-wiki10m-simple.txt
python lucene2manticore/lucene2query.py --types ext2 luceneutil/tasks/wikimedium.10M.datefacets.nostopwords.tasks > q/q-wiki10m-ext2.txt
python lucene2manticore/lucene2query.py --types simple luceneutil/tasks/wikimedium.1M.nostopwords.tasks > q/q-wiki1m-simple.txt
python lucene2manticore/lucene2query.py --types ext2 luceneutil/tasks/wikimedium.1M.nostopwords.tasks > q/q-wiki1m-ext2.txt
cat q/q-wiki*-simple.txt > q/q-simple.txt
cat q/q-wiki*-ext2.txt > q/q-ext2.txt
  1. 准备停用词
indexer -c lucene2manticore/sphinx3.conf i2_1m_no_stopwords --buildstops stopwords1k.txt 1000
head -100 stopwords1k.txt > stopwords.txt
  1. 索引数据并记住所需时间:
./indexer -c lucene2manticore/manticore.conf --all
./indexer -c lucene2manticore/sphinx3.conf --all
  1. 启动搜索守护进程
/path/to/manticore/searchd -c lucene2manticore/manticore.conf
/path/to/sphinx3/searchd -c lucene2manticore/sphinx3.conf
  1. 预热服务器

在测试之前预热搜索守护进程是值得的,例如:

cd stress-tester
for q in simple ext2; do for p in 8306 7406; do ./test.php --plugin=plain.php --data=../q/q-$q.txt -b=100 -c=8 --port=$p --index=i2_100k_stopwords_100 --maxmatches=100 --csv; done; done;

吞吐量测试用例

我们现在知道索引需要多少时间(见上文第 4 页)。让我们看看 Sphinx 3 和 Manticore Search 能提供多少吞吐量。

针对 100K 文档索引的简单查询,使用前 100 个停用词:

for port in 7406 8306; do for c in 1 4 6 8 12; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_100k_stopwords_100 --maxmatches=1000 --csv; done; done; done

针对 100K 文档索引的简单查询,使用前 1000 个停用词:

for port in 7406 8306; do for c in 1 4 6 8 12; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_100k_stopwords_1k --maxmatches=1000 --csv; done; done; done

针对 100K 文档索引的复杂查询,使用前 100 个停用词:

for port in 7406 8306; do for c in 1 4 6 8 12; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-ext2.txt -b=$batchSize -c=$c --port=$port --index=i2_100k_stopwords_100 --maxmatches=1000 --csv; done; done; done

针对 100K 文档索引的复杂查询,使用前 1000 个停用词:

for port in 7406 8306; do for c in 1 4 6 8 12; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-ext2.txt -b=$batchSize -c=$c --port=$port --index=i2_100k_stopwords_1k --maxmatches=1000 --csv; done; done; done

针对 100K 文档索引的简单查询,使用前 100 个停用词并启用形态学:

for port in 7406 8306; do for c in 1 8; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_100k_stopwords_100_morphology --maxmatches=1000 --csv; done; done; done

针对 1M 文档索引的简单查询,使用前 100 个停用词:

for port in 7406 8306; do for c in 1 8; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_1m_stopwords_100 --maxmatches=1000 --csv; done; done; done

针对 1M 文档索引的复杂查询,使用前 100 个停用词:

for port in 7406 8306; do for c in 1 8; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-ext2.txt -b=$batchSize -c=$c --port=$port --index=i2_1m_stopwords_100 --maxmatches=1000 --csv; done; done; done

针对 1M 文档索引的简单查询,使用前 100 个停用词并启用形态学:

for port in 7406 8306; do for c in 1 8; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_1m_stopwords_100_morphology --maxmatches=1000 --csv; done; done; done

针对 1M 文档索引的简单查询,使用前 100 个停用词,通过属性过滤以跳过一半的文档:

for port in 7406 8306; do for c in 1 8; do for batchSize in 1 100; do ./test.php --plugin=plain.php --data=../q/q-simple.txt -b=$batchSize -c=$c --port=$port --index=i2_1m_stopwords_100 --maxmatches=1000 --filter='ts<1199141654' --csv; done; done; done

安装Manticore Search

安装Manticore Search