You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2017/05/11 04:14:19 UTC

[couchdb] branch 3417-add-compaction-logging created (now 7e6032d)

This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a change to branch 3417-add-compaction-logging
in repository https://gitbox.apache.org/repos/asf/couchdb.git.

        at  7e6032d   add compaction logging

This branch includes the following new commits:

       new  7e6032d   add compaction logging

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].

[couchdb] 01/01: add compaction logging

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch 3417-add-compaction-logging
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7e6032d5a6f74123a6fa7c53277093608c597c8f
Author: Tony Sun <to...@cloudant.com>
AuthorDate: Wed May 10 21:16:13 2017 -0700

    add compaction logging
    
    To predict future compaction results, we log pre-compaction and
    post-compaction file sizes. These log results will be used as data
    points for regression analysis.
    
    COUCHDB-3417
---
 src/couch/src/couch_db_updater.erl              | 10 +++++++---
 src/couch_mrview/src/couch_mrview_compactor.erl | 12 +++++++++++-
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl
index 7872635..02b2a5a 100644
--- a/src/couch/src/couch_db_updater.erl
+++ b/src/couch/src/couch_db_updater.erl
@@ -218,7 +218,7 @@ handle_cast(start_compact, Db) ->
         % compact currently running, this is a no-op
         {noreply, Db}
     end;
-handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
+handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath,fd=Fd}=Db) ->
     {ok, NewFd} = couch_file:open(CompactFilepath),
     {ok, NewHeader0} = couch_file:read_header(NewFd),
     NewHeader = couch_db_header:set(NewHeader0, [
@@ -242,8 +242,12 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
             revs_limit = Db#db.revs_limit
         }),
 
-        couch_log:debug("CouchDB swapping files ~s and ~s.",
-                        [Filepath, CompactFilepath]),
+        {ok, Pre} = couch_file:bytes(Fd),
+        {ok, Post} = couch_file:bytes(NewFd),
+
+        couch_log:info("CouchDB swapping files pre-compact:~s(disk_size:"
+                "~p) and post-compact:~s(disk_size: ~p).", [Filepath,
+                Pre, CompactFilepath, Post]),
         ok = file:rename(CompactFilepath, Filepath ++ ".compact"),
         RootDir = config:get("couchdb", "database_dir", "."),
         couch_file:delete(RootDir, Filepath),
diff --git a/src/couch_mrview/src/couch_mrview_compactor.erl b/src/couch_mrview/src/couch_mrview_compactor.erl
index fabe289..1a4d7ea 100644
--- a/src/couch_mrview/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview/src/couch_mrview_compactor.erl
@@ -275,8 +275,12 @@ update_task(VID, #acc{changes=Changes, total_changes=Total}=Acc, ChangesInc) ->
 
 swap_compacted(OldState, NewState) ->
     #mrst{
+        fd = Fd
+    } = OldState,
+    #mrst{
         sig=Sig,
-        db_name=DbName
+        db_name=DbName,
+        fd=NewFd
     } = NewState,
 
     link(NewState#mrst.fd),
@@ -285,6 +289,12 @@ swap_compacted(OldState, NewState) ->
     RootDir = couch_index_util:root_dir(),
     IndexFName = couch_mrview_util:index_file(DbName, Sig),
     CompactFName = couch_mrview_util:compaction_file(DbName, Sig),
+
+    {ok, Pre} = couch_file:bytes(Fd),
+    {ok, Post} = couch_file:bytes(NewFd),
+    couch_log:info("CouchDB swapping view files pre-compact:~s(disk_size:"
+            " ~p) and post-compact:~s(disk_size: ~p).", [IndexFName, Pre,
+            CompactFName, Post]),
     ok = couch_file:delete(RootDir, IndexFName),
     ok = file:rename(CompactFName, IndexFName),
 

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.