You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Adam Kocoloski (JIRA)" <ji...@apache.org> on 2010/05/04 07:22:56 UTC
[jira] Updated: (COUCHDB-738) more efficient DB compaction (fewer
seeks)
[ https://issues.apache.org/jira/browse/COUCHDB-738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Adam Kocoloski updated COUCHDB-738:
-----------------------------------
Attachment: 738-efficient-compaction-v2.patch
Here's a new patch which applies cleanly to trunk@940505 and has one important change. In couch_view_updater:load_doc() we call couch_doc:to_doc_info() if we have a #full_doc_info{} record before calling couch_db:open_doc_int(). The reason for this is to skip the rather expensive call to get the entire revision path for the winning revision which shows up in the open_doc_int clause handling #full_doc_info{} records. With this change I get the following timings on a 100 edits/doc DB:
MegaView
Elapsed time: 5.98 (s)
Elapsed time: 5.85 (s)
Elapsed time: 4.87 (s)
SimpleView
Elapsed time: 0.86 (s)
Elapsed time: 1.05 (s)
Elapsed time: 0.75 (s)
Those are essentially identical to the timings I got earlier for trunk.
> more efficient DB compaction (fewer seeks)
> ------------------------------------------
>
> Key: COUCHDB-738
> URL: https://issues.apache.org/jira/browse/COUCHDB-738
> Project: CouchDB
> Issue Type: Improvement
> Components: Database Core
> Affects Versions: 0.9.2, 0.10.1, 0.11
> Reporter: Adam Kocoloski
> Assignee: Adam Kocoloski
> Fix For: 1.1
>
> Attachments: 738-efficient-compaction-v1.patch, 738-efficient-compaction-v2.patch
>
>
> CouchDB's database compaction algorithm walks the by_seq btree, then does a lookup in the by_id btree for every document in the database. It does this because the #full_doc_info{} record with the full revision tree is only stored in the by_id tree. I'm proposing instead to store duplicate copies of #full_doc_info{} in both trees, and to have the compactor use the by_seq tree exclusively. The net effect is significantly fewer calls to pread(), and an compaction IO pattern where reads tend to be clustered close to each other in the file.
> If the by_id tree is fully cached, or if the id tree nodes are located near the seq tree nodes, the performance improvement is small but noticeable (~10% in some simple tests). On the other hand, in the worst-case scenario of randomly-generated docids and a database much larger than main memory the improvement is huge. Joe Williams did some simple benchmarks with a 50k document, 600 MB database on a 256MB VPS. The compaction time for that DB dropped from 15m to 2m20s, so more than 6x faster.
> Storing the #full_doc_info{} in the seq tree also allows for some similar optimizations in the replicator.
> This patch might have downsides when documents have a large number of edits. These include an increase in the size of the database and slower view indexing. I expect both to be small effects.
> The patch can be applied directly to trunk@934272. Existing DBs are still readable, new updates will be written in the new format, and databases can be fully upgraded by compacting.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.