summaryrefslogtreecommitdiff
path: root/client-responsiveness
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-11-02 09:28:56 -0200
committerdrebs <drebs@riseup.net>2017-11-02 09:28:56 -0200
commitb36ebc87f449af5ad7a677350a3ccfc7d26cfb1e (patch)
tree6dd6e7a15ace7f7e15815546f43d333f74101050 /client-responsiveness
parent01e2a72ce30f0fbb4a027d3246a8ba16e00ae197 (diff)
move client responsiveness tests to a subfolder
Diffstat (limited to 'client-responsiveness')
-rw-r--r--client-responsiveness/Makefile51
-rw-r--r--client-responsiveness/README.rst86
-rw-r--r--client-responsiveness/data/series-develop-cpu-mem.pngbin0 -> 98506 bytes
-rw-r--r--client-responsiveness/data/series-develop-mostly-downloading.log200
-rw-r--r--client-responsiveness/data/series-develop.pngbin0 -> 75647 bytes
-rw-r--r--client-responsiveness/data/series-only-create.log200
-rw-r--r--client-responsiveness/data/series-only-create.pngbin0 -> 47706 bytes
-rw-r--r--client-responsiveness/data/series-vshyba-mostly-downloading.log200
-rw-r--r--client-responsiveness/data/series-vshyba-pr-downloading.pngbin0 -> 48701 bytes
-rw-r--r--client-responsiveness/data/series-vshyba-pr.log200
-rw-r--r--client-responsiveness/data/series-vshyba-pr.pngbin0 -> 78844 bytes
-rw-r--r--client-responsiveness/data/series.log200
-rw-r--r--client-responsiveness/data/sync-stats-drebs-develop-without-unicode-block.pngbin0 -> 11826 bytes
-rw-r--r--client-responsiveness/defaults.conf.example16
-rw-r--r--client-responsiveness/out/.empty0
-rw-r--r--client-responsiveness/requirements.pip3
-rwxr-xr-xclient-responsiveness/run-test.sh49
-rw-r--r--client-responsiveness/scripts/__init__.py0
-rwxr-xr-xclient-responsiveness/scripts/create_payload.py29
-rwxr-xr-xclient-responsiveness/scripts/get_client_stats.py20
-rwxr-xr-xclient-responsiveness/scripts/get_ping_rate.py19
-rwxr-xr-xclient-responsiveness/scripts/measure_perf_series.py31
-rwxr-xr-xclient-responsiveness/scripts/preload_server_database.py39
-rw-r--r--client-responsiveness/scripts/server_with_soledad_syncer.py47
-rw-r--r--client-responsiveness/scripts/soledad_sync.py96
-rwxr-xr-xclient-responsiveness/scripts/sync_stats.gnuplot23
-rw-r--r--client-responsiveness/toys/Makefile20
-rw-r--r--client-responsiveness/toys/perf.py224
-rw-r--r--client-responsiveness/toys/perf.pypy24
-rw-r--r--client-responsiveness/toys/server.py17
-rw-r--r--client-responsiveness/toys/server2.py20
-rw-r--r--client-responsiveness/toys/server3.py42
-rw-r--r--client-responsiveness/toys/tasks.py29
33 files changed, 1685 insertions, 0 deletions
diff --git a/client-responsiveness/Makefile b/client-responsiveness/Makefile
new file mode 100644
index 0000000..53228a5
--- /dev/null
+++ b/client-responsiveness/Makefile
@@ -0,0 +1,51 @@
+# Actual soledad sync
+
+soledad-sync-server:
+ twistd -n web --port 8080 --class=scripts.server_with_soledad_syncer.resource
+
+soledad-sync-server-lineprof:
+ kernprof -l ./scripts/server_with_soledad_syncer.py
+
+
+soledad-sync-server-debug:
+ #twistd --profile=stats_obj --profiler=cProfile -n web --port 8080 --class=server_with_soledad_syncer.resource
+ python -m cProfile -o sync.cprofile ./scripts/server_with_soledad_syncer.py
+
+view-lineprofile:
+ python -m line_profiler ./scripts/server_with_soledad_syncer.py.lprof
+
+
+view-profile:
+ cprofilev -f sync.cprofile
+
+measure-ping:
+ httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 --uri /ping
+
+trigger-create-docs:
+ curl localhost:8080/create-docs
+
+trigger-sync:
+ #time curl localhost:8080/start-sync
+ curl localhost:8080/start-sync
+
+trigger-stop:
+ curl localhost:8080/stop
+
+measure-series:
+ # TODO make sure we have restarted the server, send SIGNUP ?
+ # TODO rm series.log, name it with a timestamp
+ # TODO measure, first of all, the number of seconds from the beginning!!! (right now it's biased)
+ # TODO add cpu/ram usage (ping command COULD RETURN THAT!)
+ #rm -f /tmp/soledadsync/*
+ rm -f ./out/series.log
+ ./scripts/measure_perf_series.py
+
+graph-image:
+ gnuplot -e 'call "./scripts/sync_stats.gnuplot" "./out/series.log" "./out/sync-stats.png"'
+
+graph-view:
+ gnuplot -e 'call "./scripts/sync_stats.gnuplot" "./out/series.log" ""'
+
+kill:
+ killall -9 twistd
+ killall -9 python
diff --git a/client-responsiveness/README.rst b/client-responsiveness/README.rst
new file mode 100644
index 0000000..5427ecd
--- /dev/null
+++ b/client-responsiveness/README.rst
@@ -0,0 +1,86 @@
+soledad performance tests
+-------------------------
+some minimalistic benchmarks.
+small prototypes to compare async behavior under load.
+
+intended to evolve to small prototypes that:
+
+* run soledad
+* try different options for the decryption pool (inline, threads, processes).
+* serve also a simple server to test how reactor is able to respond under cpu
+ load.
+
+
+You can use the makefile to launch different servers and compare their
+performance::
+ make inline-server # executes cpu load inline
+ make thread-server # cpu load in a twisted threadpool
+ make ampoule-server # cpu load in an ampoule process pool
+ make perf # runs httperf against the server, with a moderate cpu load.
+ make perf-little # runs httperf against the server, (less requests).
+ make perf-easy # runs httperf against a no-cpu load.
+
+If you want to modify the cpu load, you can pass the FIB parameter as an
+environment variable::
+ FIB=20 make inline-server
+ curl localhost:8080/
+ $ answer is >>> 6765
+
+
+Analysis
+---------------
+Let's run some experiments, in the three situations.
+
+A) Compare a **fixed, moderate cpu load** (ie, parameters to the fib function in the range fib(25)/fib(30)) in terms of req/sec.
+
+* Very similar rates. For fib(30), this gives something ~3 req/s in my machine.
+* some overhead is appreciated.
+* RAM usage??
+* graph it!!
+
+B) Stablish a **baseline for the no-cpu** perf case (perf-easy). In my machine this varies, but
+ it's in the range 600-800 req/s. Note: since w/o cpu load this target runs very
+ fas, this can be scripted to log one measure ever 500ms or so.
+
+c) **Simultaneous easy+load**: Observe how the no-cpu perf case degrades when run
+ against each one of the three servers, *while the servers are handling a moderate cpu load*.
+ Still have to graph this properly, and measure std etc, but looking quickly
+ at data I have three conclusions (yes, I'm biased!).
+
+ * inline cpu load is a no-go: it blocks the reactor.
+ * threaded is better,
+ * but ampoule-multiprocessing is superior when we look at how responsive the reactor is still.
+
+ to do still for this case:
+
+ * RAM usage?? graph before, during, after
+ * graph it!!
+ * experiment with different parameters for the process pool.
+
+
+Run debug soledad server
+-------------------------
+You need this patched branch to run a local server with dummy authentication. I
+run this in a separate machine in your local network. I use vanilla couchdb server, with no authentication whatsoever. Warning: this is dangerous, it will eat your couch data so use it at your own
+risk::
+
+ twistd -n web --port 2323 --wsgi leap.soledad.server.debug_local_application_do_not_use
+
+Then you have to create a user for the sync to be done::
+
+ cd soledad/server/pkg
+ SOLEDAD_BYPASS_AUTH=1 ./create-user-db user-deadbeef
+
+You also have to create the shared database locally::
+
+ curl -X PUT localhost:5984/shared
+
+
+To-Do
+--------------
+* [x] make the cpu load variable (parameter to fib function: pass it as env var).
+* [x] graph req/sec in response to variable cpu loads (parameter to fib).
+* [x] graph response of perf-easy DURING a run of perf/perf-little.
+* [ ] compare the rate of responsiveness against variable cpu loads.
+* [ ] scale these minimalistic examples to realistic payload decryption using gnupg.
+
diff --git a/client-responsiveness/data/series-develop-cpu-mem.png b/client-responsiveness/data/series-develop-cpu-mem.png
new file mode 100644
index 0000000..762a915
--- /dev/null
+++ b/client-responsiveness/data/series-develop-cpu-mem.png
Binary files differ
diff --git a/client-responsiveness/data/series-develop-mostly-downloading.log b/client-responsiveness/data/series-develop-mostly-downloading.log
new file mode 100644
index 0000000..786fedc
--- /dev/null
+++ b/client-responsiveness/data/series-develop-mostly-downloading.log
@@ -0,0 +1,200 @@
+0.146611 92.0
+0.270829 116.7
+0.373923 162.5
+0.481579 151.8
+0.628966 97.4
+0.729113 164.6
+0.828087 166.3
+0.932109 155.1
+1.033571 160.5
+1.127917 192.5
+1.255497 114.3
+1.377279 120.9
+1.475758 165.2
+1.600711 139.0
+1.689222 198.9
+1.790007 162.4
+1.88861 164.3
+1.988284 164.6
+2.087045 163.4
+2.187243 167.9
+2.30939 120.2
+2.409135 160.7
+2.52891 157.6
+2.624653 176.8
+2.733529 151.7
+2.831848 164.7
+2.931747 167.6
+3.035841 156.4
+3.134986 163.6
+3.225994 197.8
+3.323722 164.7
+3.472147 128.8
+3.583002 165.2
+3.682639 157.9
+3.781186 163.3
+3.87943 166.2
+3.979335 161.3
+4.078777 165.6
+4.179432 158.8
+4.271461 192.6
+4.411085 129.8
+4.726378 36.3
+5.088731 31.6
+5.282361 66.8
+5.42562 107.0
+5.587686 91.5
+6.018959 28.3
+6.119126 178.6
+6.221279 168.2
+6.381905 84.3
+6.477005 172.5
+6.564761 202.8
+6.650418 207.9
+6.739078 206.8
+6.826413 205.7
+6.915889 191.4
+7.013164 173.1
+7.112519 161.3
+7.204698 183.0
+7.361362 95.9
+7.684715 36.1
+7.770815 204.1
+7.873552 154.8
+7.966415 193.8
+8.071128 165.8
+8.165377 176.7
+8.252686 202.4
+8.341501 195.4
+8.503823 81.3
+8.675987 98.5
+8.784715 163.3
+8.912934 136.9
+9.153374 55.2
+9.424194 54.6
+9.609199 70.6
+9.844506 53.2
+10.949191 9.5
+11.070788 135.6
+11.217772 98.2
+11.32907 170.2
+14.527689 3.2
+16.281738 6.1
+17.467019 9.0
+17.855672 29.3
+22.070654 2.4
+26.598696 2.2
+32.504955 1.7
+33.267419 15.2
+33.784956 23.0
+34.180041 28.6
+35.686187 7.1
+35.862436 83.8
+41.446228 1.8
+41.86474 30.4
+42.288466 28.0
+46.265131 2.6
+48.193722 5.4
+52.825402 2.2
+55.127358 4.4
+55.936392 14.2
+56.36726 30.7
+60.913661 2.3
+61.977608 10.3
+62.871997 12.1
+64.527267 6.2
+67.643071 3.3
+71.822888 2.5
+71.962923 104.5
+72.155263 70.5
+72.463457 37.1
+72.643338 71.2
+72.858899 58.4
+72.977696 133.7
+73.156055 82.7
+73.370837 56.8
+73.654923 41.0
+73.804983 94.8
+73.973569 76.4
+74.110361 112.8
+74.347357 53.0
+74.533721 68.2
+74.63501 164.2
+74.834398 75.1
+75.010702 73.1
+75.124536 137.9
+75.293742 91.8
+75.449806 92.2
+75.594877 98.1
+75.842575 49.0
+76.039913 62.7
+76.200103 83.5
+76.3361 110.7
+76.524775 69.4
+76.751112 57.5
+76.975107 54.3
+77.140096 78.3
+77.347596 60.8
+77.477185 112.0
+77.692261 56.5
+77.83545 98.2
+78.002956 81.6
+78.164592 83.7
+78.284227 127.2
+78.462994 76.6
+78.692386 62.8
+78.877368 79.2
+78.989764 142.2
+79.841573 12.4
+79.96535 124.3
+80.134219 81.6
+80.354758 58.2
+80.521174 97.6
+80.662098 108.0
+80.85532 64.5
+81.010912 87.5
+81.208943 66.9
+81.399531 70.9
+81.593366 66.2
+81.811071 56.1
+81.925028 136.0
+82.082549 91.5
+82.271776 73.4
+82.39467 143.1
+82.61233 60.4
+82.744271 106.2
+82.891476 93.9
+83.715519 12.8
+83.876689 83.4
+84.017277 107.9
+84.161174 98.3
+84.325526 80.9
+84.478622 88.4
+84.665816 68.0
+85.106429 25.1
+85.253272 97.3
+85.437544 82.4
+85.584829 92.7
+85.76532 71.0
+85.918936 87.6
+88.689109 3.7
+88.775545 201.8
+88.865773 199.3
+88.968487 153.6
+89.056057 195.8
+89.147794 182.2
+89.577983 25.5
+89.665385 198.3
+89.767074 163.5
+89.890315 118.7
+89.978871 191.8
+90.131569 88.9
+90.275651 97.7
+90.493247 61.5
+90.702512 60.7
+90.870657 79.2
+91.027743 90.4
+91.196294 86.9
+91.397952 63.8
+91.551759 89.4
+91.741478 66.9
diff --git a/client-responsiveness/data/series-develop.png b/client-responsiveness/data/series-develop.png
new file mode 100644
index 0000000..3d15dd0
--- /dev/null
+++ b/client-responsiveness/data/series-develop.png
Binary files differ
diff --git a/client-responsiveness/data/series-only-create.log b/client-responsiveness/data/series-only-create.log
new file mode 100644
index 0000000..0fac266
--- /dev/null
+++ b/client-responsiveness/data/series-only-create.log
@@ -0,0 +1,200 @@
+0.213816 186.9 ID list
+0.490327 118.8 ID list
+0.714129 167.7 ID list
+0.996687 115.5 ID list
+1.200839 199.5 ID list
+1.408578 197.3 ID list
+1.635415 164.7 ID list
+1.932709 108.6 ID list
+2.153094 177.2 ID list
+2.387499 158.2 ID list
+2.598951 190.7 ID list
+2.890264 111.1 ID list
+3.115351 165.2 ID list
+3.372986 130.8 ID list
+3.645531 131.7 ID list
+3.875081 165.4 ID list
+4.105412 159.0 ID list
+4.337648 156.0 ID list
+4.602455 136.6 ID list
+4.839607 153.2 ID list
+5.087392 144.2 ID list
+5.312998 165.5 ID list
+5.626485 96.8 ID list
+5.842902 181.5 ID list
+6.045917 205.3 ID list
+13.731578 2.6 ID list
+14.301957 49.2 ID list
+14.854237 50.7 ID list
+15.363468 58.8 ID list
+15.982877 59.1 ID list
+16.534854 53.5 ID list
+16.93635 77.6 ID list
+17.332324 82.4 ID list
+17.561391 166.2 ID list
+17.885877 91.5 ID list
+18.117024 166.6 ID list
+18.482077 78.7 ID list
+18.746311 149.7 ID list
+18.98452 152.9 ID list
+19.32609 109.3 ID list
+19.702296 94.1 ID list
+19.969347 132.8 ID list
+20.202765 162.1 ID list
+20.456209 133.2 ID list
+20.763067 100.2 ID list
+21.002888 158.6 ID list
+21.24464 154.6 ID list
+21.523765 135.0 ID list
+21.780232 154.4 ID list
+21.995464 185.2 ID list
+22.244468 140.4 ID list
+22.490446 162.0 ID list
+22.737085 151.5 ID list
+23.019354 120.0 ID list
+23.258988 152.2 ID list
+23.538815 113.6 ID list
+23.794621 143.7 ID list
+24.030212 161.2 ID list
+24.283894 134.8 ID list
+24.584306 136.8 ID list
+24.819653 156.8 ID list
+25.051086 172.3 ID list
+25.318041 154.3 ID list
+25.566027 145.5 ID list
+25.792918 171.2 ID list
+26.032899 154.3 ID list
+26.257716 173.0 ID list
+26.540094 126.6 ID list
+26.766161 172.8 ID list
+26.982103 178.6 ID list
+27.201199 177.2 ID list
+27.427575 176.4 ID list
+27.676939 150.3 ID list
+27.91903 154.4 ID list
+28.165187 175.6 ID list
+28.40891 163.2 ID list
+28.664342 133.3 ID list
+28.989054 93.1 ID list
+29.270171 117.6 ID list
+29.49038 180.0 ID list
+29.72724 150.9 ID list
+29.951394 177.1 ID list
+30.228598 116.8 ID list
+30.46481 152.2 ID list
+30.728593 131.2 ID list
+31.034868 106.0 ID list
+31.275938 146.1 ID list
+31.595785 105.3 ID list
+31.864782 128.1 ID list
+32.103401 169.7 ID list
+32.338883 153.9 ID list
+32.633831 112.9 ID list
+32.891073 177.0 ID list
+33.113468 174.7 ID list
+33.332699 178.1 ID list
+33.545689 192.3 ID list
+33.889055 85.8 ID list
+34.158767 135.5 ID list
+34.416535 133.2 ID list
+34.695072 122.0 ID list
+34.988695 133.0 ID list
+35.258134 134.7 ID list
+35.546735 114.7 ID list
+35.858103 99.7 ID list
+36.116488 128.7 ID list
+36.355873 153.5 ID list
+36.638149 143.0 ID list
+36.91122 125.5 ID list
+37.161923 147.2 ID list
+37.441716 122.4 ID list
+37.769663 92.7 ID list
+38.010006 149.0 ID list
+38.253974 147.3 ID list
+38.616095 78.6 ID list
+38.86092 144.7 ID list
+39.080638 181.5 ID list
+39.310824 162.7 ID list
+39.623914 98.3 ID list
+39.846205 181.9 ID list
+40.098142 134.7 ID list
+40.352073 152.3 ID list
+40.617678 147.4 ID list
+40.867362 140.6 ID list
+41.094144 172.7 ID list
+41.335384 177.2 ID list
+41.597026 128.8 ID list
+41.819464 185.1 ID list
+42.036042 188.5 ID list
+42.307802 121.0 ID list
+42.553561 153.6 ID list
+42.796216 155.7 ID list
+43.025314 165.3 ID list
+43.283041 133.1 ID list
+43.527524 145.2 ID list
+43.81343 113.7 ID list
+44.065984 155.1 ID list
+44.306813 148.4 ID list
+44.571127 128.6 ID list
+44.7895 181.1 ID list
+45.090661 103.2 ID list
+45.321063 186.3 ID list
+45.557266 151.1 ID list
+45.788135 165.6 ID list
+46.090557 105.0 ID list
+46.334451 149.0 ID list
+46.611229 127.1 ID list
+46.827646 184.6 ID list
+47.087526 149.8 ID list
+47.312812 179.8 ID list
+47.556284 149.7 ID list
+47.808458 166.7 ID list
+48.098655 109.9 ID list
+48.329057 165.7 ID list
+48.578968 153.5 ID list
+48.886247 102.3 ID list
+49.206423 95.6 ID list
+49.51713 97.8 ID list
+49.802244 111.9 ID list
+50.042975 154.0 ID list
+50.314924 120.9 ID list
+50.67837 93.1 ID list
+50.922466 153.2 ID list
+51.155438 159.1 ID list
+51.381823 162.9 ID list
+51.706683 91.7 ID list
+51.929883 170.4 ID list
+52.133481 194.2 ID list
+52.379821 180.8 ID list
+52.659693 118.1 ID list
+52.870525 189.5 ID list
+53.083267 183.7 ID list
+53.32501 160.2 ID list
+53.579321 133.4 ID list
+53.812879 153.7 ID list
+54.026326 187.6 ID list
+54.242353 186.7 ID list
+54.511878 130.5 ID list
+54.754022 162.1 ID list
+54.966919 185.7 ID list
+55.189778 168.7 ID list
+55.491523 103.1 ID list
+55.821942 91.0 ID list
+56.04183 177.0 ID list
+56.271201 159.5 ID list
+56.503133 156.2 ID list
+56.771241 124.3 ID list
+56.994325 188.6 ID list
+57.222558 162.1 ID list
+57.456749 157.5 ID list
+57.72577 120.7 ID list
+57.950269 164.9 ID list
+58.187237 175.1 ID list
+58.423814 150.3 ID list
+58.661507 154.3 ID list
+58.91041 138.1 ID list
+59.141911 178.4 ID list
+59.346358 194.4 ID list
+59.602329 135.1 ID list
+59.856585 135.5 ID list
+60.11572 130.4 ID list
diff --git a/client-responsiveness/data/series-only-create.png b/client-responsiveness/data/series-only-create.png
new file mode 100644
index 0000000..1a5de09
--- /dev/null
+++ b/client-responsiveness/data/series-only-create.png
Binary files differ
diff --git a/client-responsiveness/data/series-vshyba-mostly-downloading.log b/client-responsiveness/data/series-vshyba-mostly-downloading.log
new file mode 100644
index 0000000..31e4fdb
--- /dev/null
+++ b/client-responsiveness/data/series-vshyba-mostly-downloading.log
@@ -0,0 +1,200 @@
+0.228036 80.1 ID list
+0.427603 136.4 ID list
+0.606968 134.2 ID list
+0.776848 164.2 ID list
+0.9528 158.7 ID list
+1.138303 162.1 ID list
+1.319314 136.1 ID list
+1.478195 176.3 ID list
+1.659156 147.4 ID list
+1.820303 184.9 ID list
+2.033041 94.1 ID list
+2.204217 156.6 ID list
+2.364273 187.8 ID list
+2.563682 148.1 ID list
+2.731267 160.7 ID list
+2.920588 165.5 ID list
+3.102023 150.5 ID list
+3.262814 192.2 ID list
+3.434788 150.3 ID list
+3.601548 159.5 ID list
+3.776004 142.2 ID list
+4.014328 99.8 ID list
+4.644771 19.5 ID list
+4.924021 61.1 ID list
+5.13805 105.9 ID list
+5.391785 71.4 ID list
+5.808837 38.1 ID list
+5.993077 161.2 ID list
+6.159887 184.4 ID list
+6.323694 184.6 ID list
+6.483707 192.1 ID list
+6.6841 193.7 ID list
+6.982552 74.1 ID list
+7.195921 154.0 ID list
+7.999023 14.8 ID list
+8.182374 144.3 ID list
+8.391058 136.3 ID list
+8.700405 62.6 ID list
+9.090672 52.4 ID list
+9.315134 112.1 ID list
+11.042485 6.6 ID list
+14.410406 3.1 ID list
+15.043565 24.6 ID list
+21.608086 1.6 ID list
+28.324848 1.5 ID list
+29.152426 15.5 ID list
+29.671079 27.1 ID list
+30.973446 8.9 ID list
+31.907162 15.1 ID list
+34.089658 5.7 ID list
+42.615892 1.2 ID list
+43.20753 26.9 ID list
+43.569853 56.3 ID list
+48.0734 2.3 ID list
+55.313666 1.4 ID list
+64.314371 1.1 ID list
+74.731973 1.0 ID list
+75.582732 14.3 ID list
+75.976536 39.3 ID list
+76.289558 51.6 ID list
+76.648606 51.8 ID list
+76.913921 83.2 ID list
+77.17764 78.9 ID list
+77.44485 86.4 ID list
+77.723256 76.2 ID list
+77.995627 104.0 ID list
+78.280363 65.3 ID list
+78.588884 66.0 ID list
+78.88905 67.8 ID list
+79.162817 84.0 ID list
+79.409463 94.4 ID list
+79.705285 98.0 ID list
+79.97548 96.6 ID list
+80.25932 66.5 ID list
+80.629667 38.3 ID list
+80.885407 77.5 ID list
+81.138183 75.0 ID list
+81.384211 78.1 ID list
+81.640244 77.7 ID list
+81.887105 84.8 ID list
+82.146077 78.7 ID list
+82.46811 57.7 ID list
+82.734878 73.3 ID list
+82.964125 98.3 ID list
+83.242784 62.7 ID list
+83.491797 80.8 ID list
+83.775729 67.6 ID list
+84.058527 90.6 ID list
+84.279574 100.4 ID list
+84.517498 81.1 ID list
+84.777364 72.8 ID list
+85.557466 15.2 ID list
+85.815106 73.3 ID list
+86.113537 61.8 ID list
+86.328871 106.9 ID list
+86.572852 80.0 ID list
+86.825051 85.6 ID list
+87.157973 65.6 ID list
+87.411139 76.1 ID list
+87.63215 96.6 ID list
+88.085785 38.1 ID list
+88.3385 74.8 ID list
+88.556542 99.2 ID list
+88.815835 81.8 ID list
+89.090422 71.6 ID list
+89.34083 83.5 ID list
+89.589276 78.9 ID list
+89.900271 54.5 ID list
+90.17703 81.6 ID list
+90.44772 75.1 ID list
+90.6924 78.2 ID list
+91.005551 77.2 ID list
+91.302581 52.8 ID list
+91.467459 165.1 ID list
+91.638065 176.3 ID list
+91.965867 69.1 ID list
+92.156766 135.5 ID list
+92.31948 171.6 ID list
+92.535805 90.2 ID list
+92.760084 83.4 ID list
+93.022507 76.3 ID list
+93.289382 69.8 ID list
+93.554319 77.4 ID list
+93.816978 110.0 ID list
+94.080687 78.7 ID list
+94.33067 81.2 ID list
+94.666009 60.0 ID list
+94.920869 80.3 ID list
+95.154128 82.7 ID list
+95.439828 83.3 ID list
+95.688296 95.0 ID list
+95.912762 90.5 ID list
+96.142525 93.1 ID list
+96.380747 80.5 ID list
+96.666862 82.7 ID list
+96.944707 78.4 ID list
+97.167525 89.5 ID list
+97.456508 83.7 ID list
+97.722512 72.9 ID list
+97.945854 93.1 ID list
+98.176423 84.9 ID list
+98.436432 80.9 ID list
+98.706883 64.4 ID list
+98.944748 83.5 ID list
+99.209068 66.7 ID list
+99.422483 101.6 ID list
+99.674697 86.2 ID list
+99.950896 65.0 ID list
+100.214678 78.0 ID list
+100.444756 86.4 ID list
+100.728892 66.1 ID list
+101.001872 86.0 ID list
+101.238301 83.2 ID list
+101.518888 76.7 ID list
+101.764117 81.9 ID list
+102.033866 63.3 ID list
+102.266115 85.0 ID list
+102.489216 89.6 ID list
+102.734566 84.6 ID list
+103.052322 54.8 ID list
+103.306487 75.8 ID list
+103.589695 60.8 ID list
+103.93254 53.9 ID list
+104.191151 68.6 ID list
+104.423172 86.2 ID list
+104.6879 67.3 ID list
+105.009471 49.1 ID list
+106.286776 8.7 ID list
+106.524488 82.8 ID list
+106.80533 84.6 ID list
+107.0963 74.2 ID list
+107.36523 77.5 ID list
+107.637845 68.1 ID list
+107.944515 66.3 ID list
+108.211527 80.0 ID list
+108.612501 39.5 ID list
+108.887893 80.8 ID list
+109.150186 70.6 ID list
+109.437466 76.8 ID list
+109.758197 49.5 ID list
+110.018164 71.2 ID list
+110.28346 68.4 ID list
+110.5265 84.2 ID list
+110.854727 58.0 ID list
+111.10803 78.5 ID list
+111.366488 72.9 ID list
+111.653555 77.8 ID list
+111.906902 84.2 ID list
+112.154334 85.8 ID list
+112.396952 76.9 ID list
+112.701107 56.4 ID list
+112.99003 72.3 ID list
+113.251938 72.7 ID list
+113.596156 66.3 ID list
+113.860953 74.3 ID list
+114.117908 70.4 ID list
+114.392816 70.9 ID list
+114.685074 62.9 ID list
+114.916681 84.9 ID list
+115.146729 88.1 ID list
diff --git a/client-responsiveness/data/series-vshyba-pr-downloading.png b/client-responsiveness/data/series-vshyba-pr-downloading.png
new file mode 100644
index 0000000..840c21f
--- /dev/null
+++ b/client-responsiveness/data/series-vshyba-pr-downloading.png
Binary files differ
diff --git a/client-responsiveness/data/series-vshyba-pr.log b/client-responsiveness/data/series-vshyba-pr.log
new file mode 100644
index 0000000..ee0f21c
--- /dev/null
+++ b/client-responsiveness/data/series-vshyba-pr.log
@@ -0,0 +1,200 @@
+0.226769 165.4 ID list
+0.428275 199.2 ID list
+0.653705 165.9 ID list
+0.958381 113.4 ID list
+1.183682 165.6 ID list
+1.448082 124.5 ID list
+1.683208 153.8 ID list
+1.930027 137.4 ID list
+2.177737 138.9 ID list
+2.394018 179.6 ID list
+2.625468 162.7 ID list
+2.853907 157.8 ID list
+3.064926 180.3 ID list
+3.314492 138.9 ID list
+3.576676 139.0 ID list
+3.786005 190.9 ID list
+4.010867 167.7 ID list
+4.296315 111.0 ID list
+4.528795 160.8 ID list
+4.750022 166.7 ID list
+4.954251 200.0 ID list
+5.210428 131.4 ID list
+10.207668 4.1 ID list
+10.961331 37.7 ID list
+11.51002 50.4 ID list
+11.942256 70.9 ID list
+12.335039 70.9 ID list
+12.720052 80.9 ID list
+13.056295 89.9 ID list
+13.32745 130.1 ID list
+13.556674 165.6 ID list
+14.021434 64.8 ID list
+14.307033 142.0 ID list
+14.579057 117.8 ID list
+14.852059 121.3 ID list
+15.141004 114.6 ID list
+15.352025 188.0 ID list
+15.608332 143.4 ID list
+15.888918 117.4 ID list
+16.167553 139.6 ID list
+16.380097 186.0 ID list
+16.640293 132.5 ID list
+17.001368 79.2 ID list
+17.214652 187.2 ID list
+17.44108 183.6 ID list
+17.674578 156.3 ID list
+17.960676 109.9 ID list
+18.176139 180.2 ID list
+18.44013 125.0 ID list
+18.671841 161.7 ID list
+18.944306 131.3 ID list
+19.235804 127.5 ID list
+19.47388 152.6 ID list
+19.696698 175.5 ID list
+19.934139 159.0 ID list
+20.182195 187.2 ID list
+20.401525 185.3 ID list
+20.623198 182.3 ID list
+20.835056 191.3 ID list
+21.11296 150.4 ID list
+21.359086 154.3 ID list
+21.575298 180.0 ID list
+21.815537 147.4 ID list
+22.133673 96.0 ID list
+22.349816 180.0 ID list
+22.592902 149.2 ID list
+22.834197 151.4 ID list
+23.116058 114.9 ID list
+23.331499 179.2 ID list
+23.575281 148.0 ID list
+23.829406 137.1 ID list
+24.117479 134.5 ID list
+24.422335 101.8 ID list
+24.675686 135.9 ID list
+24.969152 112.4 ID list
+25.216782 153.4 ID list
+25.450426 155.2 ID list
+25.729932 114.0 ID list
+25.971481 146.3 ID list
+26.228341 138.3 ID list
+26.463804 164.7 ID list
+26.746956 118.0 ID list
+26.9945 141.6 ID list
+27.293541 108.5 ID list
+27.581021 111.4 ID list
+27.844978 123.4 ID list
+28.12372 119.7 ID list
+28.392221 149.7 ID list
+28.632334 155.1 ID list
+28.901952 123.5 ID list
+29.187167 113.0 ID list
+29.418962 167.6 ID list
+29.826047 66.2 ID list
+30.123232 105.6 ID list
+30.371739 146.9 ID list
+30.638881 138.5 ID list
+30.911875 125.5 ID list
+31.181253 133.5 ID list
+31.426833 145.0 ID list
+31.69309 123.7 ID list
+31.973982 118.0 ID list
+32.234236 130.7 ID list
+32.54983 99.0 ID list
+32.821387 127.6 ID list
+33.069465 154.3 ID list
+33.295135 172.0 ID list
+33.561042 127.6 ID list
+33.793076 157.7 ID list
+34.042673 142.2 ID list
+34.279166 149.6 ID list
+34.531891 149.7 ID list
+34.750157 182.9 ID list
+34.989034 147.4 ID list
+35.259255 145.1 ID list
+35.473982 183.3 ID list
+35.715347 151.5 ID list
+35.94891 157.4 ID list
+36.282891 87.6 ID list
+36.524023 155.5 ID list
+36.755419 157.2 ID list
+36.988033 159.8 ID list
+37.290558 103.1 ID list
+37.52663 153.9 ID list
+37.769042 147.9 ID list
+38.045055 150.5 ID list
+38.332563 111.1 ID list
+38.550424 181.9 ID list
+38.781127 153.3 ID list
+39.103472 94.9 ID list
+39.33811 155.8 ID list
+39.555575 176.9 ID list
+39.767596 184.6 ID list
+40.04727 113.5 ID list
+40.277605 157.5 ID list
+40.52903 140.2 ID list
+40.738734 188.4 ID list
+41.006576 122.0 ID list
+41.271043 131.2 ID list
+41.478284 195.1 ID list
+41.718522 156.8 ID list
+41.951956 158.6 ID list
+42.207546 138.1 ID list
+42.431008 170.4 ID list
+42.687486 132.2 ID list
+42.924365 148.4 ID list
+43.165376 149.1 ID list
+43.42434 153.3 ID list
+43.662875 172.4 ID list
+43.903559 162.6 ID list
+44.177119 149.8 ID list
+44.396095 175.4 ID list
+44.657615 133.1 ID list
+44.88581 166.7 ID list
+45.130672 168.7 ID list
+45.363151 153.7 ID list
+45.582532 171.6 ID list
+45.842361 147.2 ID list
+46.118406 116.9 ID list
+46.375091 140.7 ID list
+46.642461 134.8 ID list
+46.86592 174.3 ID list
+47.206481 85.1 ID list
+47.448929 143.6 ID list
+47.674953 165.7 ID list
+47.981809 110.9 ID list
+48.224895 142.6 ID list
+48.485071 130.3 ID list
+48.72196 157.1 ID list
+49.02134 105.9 ID list
+49.252382 160.5 ID list
+49.544804 109.5 ID list
+49.797109 139.3 ID list
+50.067336 141.0 ID list
+50.32647 127.9 ID list
+50.576668 141.1 ID list
+50.802438 167.6 ID list
+51.031084 164.4 ID list
+51.343853 95.4 ID list
+51.585534 148.0 ID list
+51.83629 140.9 ID list
+52.081639 155.2 ID list
+52.396489 97.1 ID list
+52.650758 133.9 ID list
+52.889931 150.2 ID list
+53.223298 87.2 ID list
+53.446989 163.9 ID list
+53.701248 138.4 ID list
+54.001002 109.8 ID list
+54.274181 130.9 ID list
+54.50542 164.7 ID list
+54.727025 167.7 ID list
+54.995665 145.1 ID list
+55.21863 165.1 ID list
+55.447332 160.7 ID list
+55.671274 166.7 ID list
+55.953357 130.7 ID list
+56.212118 137.4 ID list
+56.464827 140.9 ID list
+56.695485 161.5 ID list
+56.975309 112.0 ID list
diff --git a/client-responsiveness/data/series-vshyba-pr.png b/client-responsiveness/data/series-vshyba-pr.png
new file mode 100644
index 0000000..dd4e9d6
--- /dev/null
+++ b/client-responsiveness/data/series-vshyba-pr.png
Binary files differ
diff --git a/client-responsiveness/data/series.log b/client-responsiveness/data/series.log
new file mode 100644
index 0000000..e6cfcb5
--- /dev/null
+++ b/client-responsiveness/data/series.log
@@ -0,0 +1,200 @@
+0.210047 56.3
+0.316841 138.4
+0.419286 140.4
+0.521831 139.7
+0.649547 112.3
+0.7747 136.8
+0.877166 143.6
+0.97634 145.3
+1.095328 120.5
+1.207807 121.1
+1.311972 134.4
+1.409 150.3
+1.516224 137.5
+1.66495 88.2
+1.790899 106.8
+1.914703 110.7
+2.037933 113.1
+2.153851 116.4
+2.259358 132.0
+2.381434 116.0
+2.485015 143.8
+2.644692 77.4
+2.760346 125.3
+2.879985 113.5
+2.979379 144.2
+3.110818 97.6
+3.215562 131.7
+3.329797 117.7
+3.433906 143.3
+3.590632 79.5
+3.694265 136.3
+3.801984 131.1
+3.922523 110.9
+4.050104 101.4
+4.15811 135.7
+4.261787 136.9
+4.363309 138.7
+4.481696 112.4
+4.60274 109.0
+4.738066 97.9
+4.840082 137.5
+4.957175 117.7
+5.071918 121.3
+5.263489 67.6
+5.433107 82.1
+5.584194 87.6
+5.722112 96.6
+5.825947 140.6
+5.948904 108.0
+6.055644 132.7
+6.183554 107.7
+6.306964 107.1
+6.424886 120.5
+6.59423 79.3
+6.726049 99.0
+6.833721 131.2
+6.933688 139.3
+7.074586 90.8
+7.199221 106.4
+7.315739 117.5
+7.472213 79.1
+7.672748 60.8
+7.850607 69.0
+8.027069 70.6
+8.203116 80.7
+8.402747 63.1
+8.612229 59.1
+8.854187 55.6
+8.973681 120.0
+9.099607 103.5
+9.221818 109.5
+9.36211 95.1
+9.477103 117.3
+9.603077 106.4
+9.714717 126.7
+9.818982 143.1
+9.94438 107.1
+10.070115 105.1
+10.169238 144.6
+10.320133 83.4
+10.427798 130.2
+10.552177 106.8
+10.675741 107.5
+10.813704 91.7
+10.946708 100.0
+11.174081 59.3
+11.397472 59.6
+11.529954 99.8
+11.653342 106.2
+11.763712 126.1
+11.891591 101.8
+11.991629 142.8
+12.228416 55.3
+12.351251 117.9
+12.477629 103.1
+12.594639 113.5
+12.725439 97.6
+12.845845 109.5
+12.981984 104.6
+13.117733 95.3
+13.239068 109.9
+13.384764 88.4
+13.670487 45.2
+14.079312 28.6
+14.247621 104.4
+14.429241 69.8
+14.645767 65.9
+14.84522 63.1
+14.958642 130.6
+15.14819 62.5
+15.298423 88.7
+15.424745 103.2
+15.525933 140.2
+15.645346 110.6
+15.744282 144.1
+15.909168 77.9
+16.138961 53.3
+16.338066 60.7
+16.447721 129.5
+16.635302 63.4
+16.841896 56.5
+17.012547 72.0
+17.182396 76.5
+17.296235 120.6
+17.416205 109.6
+17.551178 97.8
+17.654689 142.8
+17.773628 113.6
+17.923737 92.8
+18.055348 98.6
+18.159398 134.7
+18.267011 136.6
+18.378633 136.7
+18.64627 42.9
+18.91044 45.5
+19.162734 50.2
+19.426078 58.2
+19.719835 39.0
+20.085218 40.6
+20.405663 40.8
+20.654743 48.2
+20.999818 43.4
+21.21637 55.7
+21.427141 57.6
+21.659958 52.4
+21.962387 38.3
+22.192803 53.9
+22.412744 55.4
+22.612556 60.7
+22.838938 52.5
+23.016574 70.5
+23.241087 53.2
+23.551507 53.2
+23.871489 43.7
+24.117979 49.7
+24.369804 46.9
+24.640464 52.2
+24.878516 65.7
+24.996105 113.3
+25.109084 127.7
+25.230275 108.7
+25.348385 116.5
+25.46849 111.0
+25.583052 119.7
+25.726719 97.3
+25.827865 143.0
+25.926775 145.7
+26.028083 144.3
+26.156272 107.2
+26.275749 111.5
+26.38198 136.2
+26.485271 139.5
+26.654527 83.1
+26.774963 115.4
+26.888794 121.0
+27.005365 121.9
+27.128847 111.9
+27.247169 112.8
+27.346957 141.9
+27.537317 63.1
+27.683703 88.4
+27.799036 121.4
+27.928876 101.2
+28.282746 40.1
+28.662626 29.8
+29.089195 33.2
+29.353389 49.2
+29.639542 48.9
+29.954964 41.9
+30.379812 28.9
+30.647427 53.3
+30.883988 49.9
+31.185856 47.8
+31.326121 106.7
+31.616247 46.1
+31.761444 90.3
+31.894652 98.3
+32.124868 51.3
+32.377793 45.7
+32.690502 37.2
diff --git a/client-responsiveness/data/sync-stats-drebs-develop-without-unicode-block.png b/client-responsiveness/data/sync-stats-drebs-develop-without-unicode-block.png
new file mode 100644
index 0000000..80846e7
--- /dev/null
+++ b/client-responsiveness/data/sync-stats-drebs-develop-without-unicode-block.png
Binary files differ
diff --git a/client-responsiveness/defaults.conf.example b/client-responsiveness/defaults.conf.example
new file mode 100644
index 0000000..e997c53
--- /dev/null
+++ b/client-responsiveness/defaults.conf.example
@@ -0,0 +1,16 @@
+[server]
+host = http://localhost:2424
+
+[client]
+uuid = 1234567890abcdef
+basedir = /tmp/soledad_client_test
+passphrase = 12345678
+
+[sync]
+num_docs = 100
+payload = /tmp/payload
+payload_size = 500
+auth_token = an-auth-token
+
+[test]
+stats_file = ./out/stats.json
diff --git a/client-responsiveness/out/.empty b/client-responsiveness/out/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client-responsiveness/out/.empty
diff --git a/client-responsiveness/requirements.pip b/client-responsiveness/requirements.pip
new file mode 100644
index 0000000..324ebdf
--- /dev/null
+++ b/client-responsiveness/requirements.pip
@@ -0,0 +1,3 @@
+klein
+ampoule
+service-identity
diff --git a/client-responsiveness/run-test.sh b/client-responsiveness/run-test.sh
new file mode 100755
index 0000000..66bf985
--- /dev/null
+++ b/client-responsiveness/run-test.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+export SOLEDAD_STATS=1
+
+# assume the cli is in the environment
+CLI="soledad_test_env.py"
+
+_server_setup() {
+ ${CLI} couch start
+ ${CLI} shared-db create
+ ${CLI} token-db create
+ ${CLI} token-db insert-token #--uuid 1234567890abcdefa --auth-token an-auth-token2
+ ${CLI} soledad-server start
+}
+
+function _server_reset() {
+ ${CLI} user-db delete #--uuid 1234567890abcdefa
+ ${CLI} user-db create #--uuid 1234567890abcdefa
+ ./scripts/create_payload.py
+ ./scripts/preload_server_database.py
+}
+
+function _client_reset() {
+ rm -rf /tmp/soledad_client_test
+}
+
+_server_setup
+
+if [ ! "${SKIP_SERVER_RESET}" ]; then
+ _server_reset
+fi
+if [ ! "${SKIP_CLIENT_RESET}" ]; then
+ _client_reset
+fi
+
+# start local test server
+make soledad-sync-server | grep -v stats | grep -v ping &
+sleep 5
+
+# create documents
+make trigger-create-docs
+
+# launch background series measurement
+make measure-series &
+sleep 5 # wait a bit for some data points
+
+# trigger sync and stop afterwards
+make trigger-sync
+make trigger-stop
diff --git a/client-responsiveness/scripts/__init__.py b/client-responsiveness/scripts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client-responsiveness/scripts/__init__.py
diff --git a/client-responsiveness/scripts/create_payload.py b/client-responsiveness/scripts/create_payload.py
new file mode 100755
index 0000000..d051661
--- /dev/null
+++ b/client-responsiveness/scripts/create_payload.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+"""
+Create a payload file in disk to use during tests. Reads the name of the file
+and the intended size of the payload from the "defaults.conf" file:
+
+ PAYLOAD = /path/to/payload/file
+ PAYLOAD_SIZE = 500 # in Kb
+"""
+
+import os
+from ConfigParser import ConfigParser
+
+parser = ConfigParser()
+parser.read('defaults.conf')
+
+PAYLOAD = parser.get('sync', 'payload')
+PAYLOAD_SIZE = int(parser.get('sync', 'payload_size')) * 1024
+
+if os.path.isfile(PAYLOAD):
+ os.unlink(PAYLOAD)
+
+content = 'a' * 1024
+
+with open(PAYLOAD, 'w') as f:
+ length = 0
+ while length < PAYLOAD_SIZE:
+ f.write(content)
+ length += len(content)
diff --git a/client-responsiveness/scripts/get_client_stats.py b/client-responsiveness/scripts/get_client_stats.py
new file mode 100755
index 0000000..59f9aa6
--- /dev/null
+++ b/client-responsiveness/scripts/get_client_stats.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+"""
+Get stats from dummy server running Soledad Client and spit them out.
+"""
+
+import commands
+import urllib
+import psutil
+
+stats = urllib.urlopen('http://localhost:8080/stats').read().split()
+
+pid, sync_phase, sync_exchange_phase = stats
+
+res = commands.getoutput("ps -p " + pid + " -o \%cpu,\%mem")
+splitted = res.split()
+cpu = splitted[2]
+mem = splitted[3]
+
+print cpu, mem, sync_phase, sync_exchange_phase
diff --git a/client-responsiveness/scripts/get_ping_rate.py b/client-responsiveness/scripts/get_ping_rate.py
new file mode 100755
index 0000000..19d63d1
--- /dev/null
+++ b/client-responsiveness/scripts/get_ping_rate.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+"""
+Measure the connection rate to the dummy server running Soledad Client using
+httperf and spit it out.
+"""
+
+import commands
+import re
+
+# ORIGINAL, STANDARD MEASURE (TOTALLY RANDOM)
+#res = commands.getoutput(
+ #'httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 '
+ #'--uri /ping | grep "Connection rate"')
+
+res = commands.getoutput(
+ 'httperf --server localhost --port 8080 --num-calls 5 --num-conns 10 '
+ '--uri /ping | grep "Connection rate"')
+print re.findall('[-+]?([0-9]*\.?[0-9]+)', res)[0]
diff --git a/client-responsiveness/scripts/measure_perf_series.py b/client-responsiveness/scripts/measure_perf_series.py
new file mode 100755
index 0000000..587ff7a
--- /dev/null
+++ b/client-responsiveness/scripts/measure_perf_series.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import commands
+import datetime
+
+# How many points to measure. Make sure that you leave the baseline
+# running for a significative amount before triggering the sync, it's possible
+# you have significant variability in there.
+POINTS = 400
+
+SCALE = 50
+
+commands.getoutput('echo time req/s cpu mem sync_phase sync_exchange_phase > ./out/series.log')
+start = datetime.datetime.now()
+
+for i in range(POINTS):
+ value = commands.getoutput('./scripts/get_ping_rate.py')
+ print "Step", i, "...", value
+ stats = commands.getoutput('./scripts/get_client_stats.py')
+ cpu, mem, sync_phase, sync_exchange_phase = stats.split()
+ sync_phase = str(int(sync_phase)*SCALE)
+ sync_exchange_phase = str(int(sync_exchange_phase)*SCALE)
+ now = datetime.datetime.now()
+ secs = (now - start).total_seconds()
+ try:
+ # make it so the script exits succesfully when the server is dead
+ commands.getoutput(
+ 'echo %s\t%s\t%s\t%s\t%s\t%s >> ./out/series.log' \
+ % (secs, value, cpu, mem, sync_phase, sync_exchange_phase))
+ except ValueError:
+ break
diff --git a/client-responsiveness/scripts/preload_server_database.py b/client-responsiveness/scripts/preload_server_database.py
new file mode 100755
index 0000000..95e8cfd
--- /dev/null
+++ b/client-responsiveness/scripts/preload_server_database.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+"""
+Preload the server database with a certain amount of documents so we can
+receive them during the sync process and gather meaningful statistics for that
+specific phase of sync.
+
+Gets uuid, payload file path and amount of documents to preload from
+"defaults.conf" config file:
+
+ UUID = some-uuid
+ PAYLOAD = /path/to/payload/file
+ NUM_DOCS = 100
+"""
+
+import os
+from ConfigParser import ConfigParser
+from leap.soledad.common.couch import CouchDatabase
+
+parser = ConfigParser()
+parser.read('defaults.conf')
+
+UUID = parser.get('client', 'uuid')
+PAYLOAD = parser.get('sync', 'payload')
+NUM_DOCS = int(parser.get('sync', 'num_docs'))
+
+db = CouchDatabase.open_database(
+ 'http://127.0.0.1:5984/user-%s' % UUID,
+ False) # should create database?
+
+payload = None
+if os.path.isfile(PAYLOAD):
+ with open(PAYLOAD, 'r') as f:
+ payload = f.read()
+
+for i in xrange(NUM_DOCS):
+ db.create_doc({'payload': payload})
+
+db.close()
diff --git a/client-responsiveness/scripts/server_with_soledad_syncer.py b/client-responsiveness/scripts/server_with_soledad_syncer.py
new file mode 100644
index 0000000..2890e04
--- /dev/null
+++ b/client-responsiveness/scripts/server_with_soledad_syncer.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+#!/usr/bin/env python
+
+
+import os
+from klein import run, route, resource
+import soledad_sync as sync
+from twisted.internet import reactor
+import datetime
+
+
+@route('/create-docs')
+def create_docs(request):
+ d = sync.create_docs()
+ return d
+
+
+@route('/start-sync')
+def start_sync(request):
+ d = sync.start_sync()
+ return d
+
+
+@route('/ping')
+def ping(request):
+ return 'easy!'
+
+
+@route('/pid')
+def pid(request):
+ return str(os.getpid())
+
+
+@route('/stop')
+def stop(request):
+ reactor.callLater(1, reactor.stop)
+ return ''
+
+@route('/stats')
+def stats(request):
+ pid = os.getpid()
+ sync_phase, sync_exchange_phase = sync.stats()
+ return "%d %d %d" % (pid, sync_phase, sync_exchange_phase)
+
+
+if __name__ == "__main__":
+ run("localhost", 8080)
diff --git a/client-responsiveness/scripts/soledad_sync.py b/client-responsiveness/scripts/soledad_sync.py
new file mode 100644
index 0000000..8c6442f
--- /dev/null
+++ b/client-responsiveness/scripts/soledad_sync.py
@@ -0,0 +1,96 @@
+import os
+import json
+from ConfigParser import ConfigParser
+from leap.soledad.client.api import Soledad
+from twisted.internet import defer, reactor
+from twisted.internet.task import deferLater
+
+
+# get configs from file
+parser = ConfigParser()
+parser.read('defaults.conf')
+
+HOST = parser.get('server', 'host')
+
+UUID = parser.get('client', 'uuid')
+CLIENT_BASEDIR = parser.get('client', 'basedir')
+PASSPHRASE = parser.get('client', 'passphrase')
+
+NUM_DOCS = int(parser.get('sync', 'num_docs'))
+PAYLOAD = parser.get('sync', 'payload')
+AUTH_TOKEN = parser.get('sync', 'auth_token')
+
+STATS_FILE = parser.get('test', 'stats_file')
+
+
+DO_THESEUS = os.environ.get('THESEUS', False)
+
+
+def _get_soledad_instance_from_uuid(uuid, passphrase, basedir, server_url,
+ cert_file, token):
+ secrets_path = os.path.join(basedir, '%s.secret' % uuid)
+ local_db_path = os.path.join(basedir, '%s.db' % uuid)
+ return Soledad(
+ uuid,
+ unicode(passphrase),
+ secrets_path=secrets_path,
+ local_db_path=local_db_path,
+ server_url=server_url,
+ cert_file=cert_file,
+ auth_token=token,
+ defer_encryption=True,
+ syncable=True)
+
+
+def _get_soledad_instance():
+ return _get_soledad_instance_from_uuid(
+ UUID, PASSPHRASE, CLIENT_BASEDIR, HOST, '', AUTH_TOKEN)
+
+s = _get_soledad_instance()
+
+
+def create_docs():
+ global s
+ # get content for docs
+ payload = 'a' * 10
+ if os.path.isfile(PAYLOAD):
+ with open(PAYLOAD, 'r') as f:
+ payload = f.read()
+
+ # create docs
+ cd = []
+ for i in range(NUM_DOCS):
+ cd.append(s.create_doc({'payload': payload}))
+ d = defer.gatherResults(cd)
+
+ d.addCallback(lambda _: s.get_all_docs())
+ d.addCallback(lambda result: "%d docs created, %d docs on db" % (NUM_DOCS, result[0]))
+ #d.addCallback(lambda _: s.close())
+
+ return d
+
+
+def start_sync():
+ global s
+
+ if DO_THESEUS:
+ from theseus import Tracer
+ t = Tracer()
+ t.install()
+
+ def stop_tracing(_):
+ if DO_THESEUS:
+ with open('callgrind.theseus', 'wb') as outfile:
+ t.write_data(outfile)
+ print "STOPPED TRACING, DUMPED IN CALLGRIND.THESEUS<<<<"
+
+ cd = []
+
+ d = s.sync()
+ d.addCallback(stop_tracing)
+
+ return d
+
+def stats():
+ global s
+ return s.sync_stats()
diff --git a/client-responsiveness/scripts/sync_stats.gnuplot b/client-responsiveness/scripts/sync_stats.gnuplot
new file mode 100755
index 0000000..7fdf29a
--- /dev/null
+++ b/client-responsiveness/scripts/sync_stats.gnuplot
@@ -0,0 +1,23 @@
+#!/usr/bin/gnuplot
+
+infile="$0"
+outfile="$1"
+
+# maybe save image file
+if (outfile ne '') \
+ set term png size 1000,400; \
+ set output "./out/sync-stats.png"
+
+# make the graph beautiful
+set title 'Soledad Sync Phases'
+set xtics 10
+set ytics 50
+set grid
+set key outside
+
+# plot!
+plot for [col=2:6] infile using 1:col with linespoints title columnheader
+
+# pause when not saving image file
+if (outfile eq '') \
+ pause -1
diff --git a/client-responsiveness/toys/Makefile b/client-responsiveness/toys/Makefile
new file mode 100644
index 0000000..33761a1
--- /dev/null
+++ b/client-responsiveness/toys/Makefile
@@ -0,0 +1,20 @@
+# Simple PoC toys
+
+perf:
+ httperf --server localhost --port 8080 --num-calls 200 --num-conns 20 --uri /
+
+perf-little:
+ httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 --uri /
+
+perf-easy:
+ httperf --server localhost --port 8080 --num-calls 5 --num-conns 20 --uri /hi
+
+inline-server:
+ python server.py
+
+thread-server:
+ python server2.py
+
+ampoule-server:
+ python server3.py
+
diff --git a/client-responsiveness/toys/perf.py2 b/client-responsiveness/toys/perf.py2
new file mode 100644
index 0000000..ef2eeb2
--- /dev/null
+++ b/client-responsiveness/toys/perf.py2
@@ -0,0 +1,24 @@
+httperf --server localhost --port 8080 --uri --rate 2000 --num-calls 5000
+httperf --client=0/1 --server=localhost --port=8080 --uri=--rate --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=5000
+Maximum connect burst length: 0
+
+Total: connections 1 requests 5000 replies 5000 test-duration 6.615 s
+
+Connection rate: 0.2 conn/s (6615.0 ms/conn, <=1 concurrent connections)
+Connection time [ms]: min 6615.0 avg 6615.0 max 6615.0 median 6614.5 stddev 0.0
+Connection time [ms]: connect 0.1
+Connection length [replies/conn]: 5000.000
+
+Request rate: 755.9 req/s (1.3 ms/req)
+Request size [B]: 67.0
+
+Reply rate [replies/s]: min 768.0 avg 768.0 max 768.0 stddev 0.0 (1 samples)
+Reply time [ms]: response 1.3 transfer 0.0
+Reply size [B]: header 136.0 content 233.0 footer 0.0 (total 369.0)
+Reply status: 1xx=0 2xx=0 3xx=0 4xx=5000 5xx=0
+
+CPU time [s]: user 4.87 system 1.56 (user 73.7% system 23.6% total 97.3%)
+Net I/O: 321.8 KB/s (2.6*10^6 bps)
+
+Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
+Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
diff --git a/client-responsiveness/toys/perf.pypy b/client-responsiveness/toys/perf.pypy
new file mode 100644
index 0000000..671cfa2
--- /dev/null
+++ b/client-responsiveness/toys/perf.pypy
@@ -0,0 +1,24 @@
+httperf --server localhost --port 8080 --uri --rate 2000 --num-calls 5000
+httperf --client=0/1 --server=localhost --port=8080 --uri=--rate --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=5000
+Maximum connect burst length: 0
+
+Total: connections 1 requests 5000 replies 5000 test-duration 7.649 s
+
+Connection rate: 0.1 conn/s (7648.8 ms/conn, <=1 concurrent connections)
+Connection time [ms]: min 7648.8 avg 7648.8 max 7648.8 median 7648.5 stddev 0.0
+Connection time [ms]: connect 0.1
+Connection length [replies/conn]: 5000.000
+
+Request rate: 653.7 req/s (1.5 ms/req)
+Request size [B]: 67.0
+
+Reply rate [replies/s]: min 574.0 avg 574.0 max 574.0 stddev 0.0 (1 samples)
+Reply time [ms]: response 1.5 transfer 0.0
+Reply size [B]: header 136.0 content 233.0 footer 0.0 (total 369.0)
+Reply status: 1xx=0 2xx=0 3xx=0 4xx=5000 5xx=0
+
+CPU time [s]: user 5.56 system 1.80 (user 72.6% system 23.5% total 96.2%)
+Net I/O: 278.3 KB/s (2.3*10^6 bps)
+
+Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
+Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
diff --git a/client-responsiveness/toys/server.py b/client-responsiveness/toys/server.py
new file mode 100644
index 0000000..4afa31b
--- /dev/null
+++ b/client-responsiveness/toys/server.py
@@ -0,0 +1,17 @@
+import os
+from klein import run, route
+import tasks
+
+FIB = os.environ.get('FIB', tasks.FIB_DEFAULT)
+
+
+@route('/')
+def home(request):
+ return 'answer is >>> %s\n' % tasks.fib(FIB)
+
+@route('/hi')
+def ping(request):
+ return 'easy!'
+
+if __name__ == "__main__":
+ run("localhost", 8080)
diff --git a/client-responsiveness/toys/server2.py b/client-responsiveness/toys/server2.py
new file mode 100644
index 0000000..268c7c5
--- /dev/null
+++ b/client-responsiveness/toys/server2.py
@@ -0,0 +1,20 @@
+import os
+from klein import run, route
+from twisted.internet.threads import deferToThread
+import tasks
+
+FIB = os.environ.get('FIB', tasks.FIB_DEFAULT)
+
+
+@route('/')
+def home(request):
+ d = deferToThread(tasks.fib, FIB)
+ d.addCallback(lambda result: 'answer is >>> %s\n' % result)
+ return d
+
+@route('/hi')
+def ping(request):
+ return 'easy!'
+
+if __name__ == "__main__":
+ run("localhost", 8080)
diff --git a/client-responsiveness/toys/server3.py b/client-responsiveness/toys/server3.py
new file mode 100644
index 0000000..d737d4b
--- /dev/null
+++ b/client-responsiveness/toys/server3.py
@@ -0,0 +1,42 @@
+import os
+import sys
+from klein import run, route
+
+from twisted.internet import defer
+from twisted.internet import reactor
+from twisted.python import log
+
+from ampoule import pool
+
+import tasks
+
+log.startLogging(sys.stdout)
+
+FIB = os.environ.get('FIB', tasks.FIB_DEFAULT)
+
+
+@route('/')
+def home(request):
+ d = pp.doWork(tasks.Fib, n=int(FIB))
+ d.addCallback(lambda res: 'answer is >>> {r}\n'.format(r=res['fib']))
+ return d
+
+@route('/hi')
+def ping(request):
+ return 'easy!'
+
+
+pp = None
+
+
+@defer.inlineCallbacks
+def start_pool():
+ global pp
+ # TODO get max number of processors
+ pp = pool.ProcessPool(tasks.FibCalculator, min=1, max=4)
+ print 'starting pool'
+ yield pp.start()
+
+if __name__ == "__main__":
+ reactor.callWhenRunning(start_pool)
+ run("localhost", 8080)
diff --git a/client-responsiveness/toys/tasks.py b/client-responsiveness/toys/tasks.py
new file mode 100644
index 0000000..3f8b85d
--- /dev/null
+++ b/client-responsiveness/toys/tasks.py
@@ -0,0 +1,29 @@
+import os
+from twisted.protocols import amp
+from ampoule import child
+
+FIB_DEFAULT = 30
+
+
+def fib(n):
+ '''very silly fibonacci function.
+ do not try to optimize this, the idea is to make your cpu suffer for a
+ while'''
+ n = int(n)
+ if n <= 2:
+ return 1
+ else:
+ return fib(n-1) + fib(n-2)
+
+# ampoule stuff
+
+class Fib(amp.Command):
+ arguments = [('n', amp.Integer())]
+ response = [('fib', amp.Integer())]
+
+
+class FibCalculator(child.AMPChild):
+ @Fib.responder
+ def fib(self, n):
+ #print "FIB FUNCTION CALLED WITH", n
+ return {"fib": fib(n)}