Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13D2D177BE for ; Fri, 29 May 2015 17:29:25 +0000 (UTC) Received: (qmail 63782 invoked by uid 500); 29 May 2015 17:29:24 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 63721 invoked by uid 500); 29 May 2015 17:29:24 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 63710 invoked by uid 99); 29 May 2015 17:29:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 17:29:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5BDBDE0329; Fri, 29 May 2015 17:29:24 +0000 (UTC) From: robertkowalski To: dev@couchdb.apache.org Reply-To: dev@couchdb.apache.org Message-ID: Subject: [GitHub] couchdb-couch pull request: perf: http layer - cache couchdb versi... Content-Type: text/plain Date: Fri, 29 May 2015 17:29:24 +0000 (UTC) GitHub user robertkowalski opened a pull request: https://github.com/apache/couchdb-couch/pull/56 perf: http layer - cache couchdb version I have taken a look at our http stack with erlang:trace and flamegraphs. It turned out that we spend a lot of our time for ever request in the function couch_server:get_version which simply gets the current CouchDB version. [1] ![http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--unpatched-second-request.png](http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--unpatched-second-request.png) So I tried to memoize it, with pretty good results [2]. ![http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--patched-second-request.png](http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--patched-second-request.png) I benchmarked the unclustered interface, but (almost?) all our requests are accessing this function so it should also be beneficial for chttpd & friends. After a better looking flamegraph i tried to run Apache ab [[3]](http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/results-ab.txt) on it. All benchmarks (also the flamegraph creation) were run using this test protocol: 1. turn off all auto starting apps, especially dropbox & co 2. run make with path 3. reboot 4. wait 60secs 5. boot cluster and wait until successful connected 6. wait 60secs 7. run test Apache „ab“: 10000 requests, concurrency 130, reading one doc, unclustered interface: old version, overall run times: test 1: 3.846 test 2: 3.830 patched version, overall run times: test 1: 3.439 test 2: 3.577 mean difference: (3.846 + 3.830) / (3.439 + 3.577) * 100 patched version is ~9.4% faster The implementation of the cache itself is a simple orddict that is meant for caching a small amount of these time consuming operations. [1] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--unpatched-second-request.png [2] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--patched-second-request.png [3] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/results-ab.txt You can merge this pull request into a Git repository by running: $ git pull https://github.com/robertkowalski/couchdb-couch increase-perf Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/56.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #56 ---- commit 4f205dc0f6210ce342ea65994c1eef46674ee8f0 Author: Robert Kowalski Date: 2015-05-29T13:25:00Z perf: http layer - cache couchdb version I have taken a look at our http stack with erlang:trace and flamegraphs. It turned out that we spend a lot of our time for ever request in the function couch_server:get_version which simply gets the current CouchDB version. [1] So I tried to memoize it, with pretty good results [2]. I benchmarked the unclustered interface, but (almost?) all our requests are accessing this function so it should also be beneficial for chttpd & friends. After a better looking flamegraph i tried to run Apache ab [3] on it. All benchmarks (also the flamegraph creation) were run using this test protocol: 1. turn off all auto starting apps, especially dropbox & co 2. run make with path 3. reboot 4. wait 60secs 5. boot cluster and wait until successful connected 6. wait 60secs 7. run test Apache „ab“: 10000 requests, concurrency 130, reading one doc, unclustered interface: old version, overall run times: test 1: 3.846 test 2: 3.830 patched version, overall run times: test 1: 3.439 test 2: 3.577 mean difference: (3.846 + 3.830) / (3.439 + 3.577) * 100 patched version is ~9.4% faster The implementation of the cache itself is a simple orddict that is meant for caching a small amount of these time consuming operations. [1] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--unpatched-second-request.png [2] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/flame--patched-second-request.png [3] http://robert-kowalski.de/assets/data/2015-05-29-erlang-perf/results-ab.txt ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---