dump_systemstate: Replace extremely inefficient vconftool with buxton2ctl 11/189811/7
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 20 Sep 2018 19:32:11 +0000 (21:32 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 16 Nov 2018 13:00:17 +0000 (14:00 +0100)
vconftool and buxton2ctl access the same data. vconftool is shell script
which under the hood uses buxton2ctl. However, it does so in very inefficient
manner - to get the keys it calls buxton2ctl once, but to get key values
it calls buxton2ctl for each key.  This causes it to fork

On TM1 target with 548 keys in "db/" this means 548 fork & buxton2ctl execs.
buxton2ctl gets the data from server via socket connection, meaning that
it needs to connect & write request and wait for response.

All of this together sums up to absurd - `buxton2ctl dump system` takes ~50ms,
while `vconftool get db/ -r` takes more than 12seconds - which is roughly
250 times slower!

  sh-3.2# time buxton2ctl dump system >/dev/null
  real    0m0.050s
  user    0m0.040s
  sys     0m0.000s

  sh-3.2# time vconftool get db/ -r >/dev/null
  real    0m12.344s
  user    0m0.560s
  sys     0m1.190s

With this change applied, dump_systemstate invocation time drops from
13seconds to 1.5-2sec (without logs), and from 13 seconds to 3-4secs (with
logs, ie. -k -d -j options).

Change-Id: I0cb042d18e5322d8246bf03ee142117217c83b4c

packaging/crash-worker.spec
src/dump_systemstate/dump_systemstate.c

index 024821a..1bdc552 100644 (file)
@@ -41,6 +41,7 @@ Requires: zip
 Requires: libelf
 Requires: libdw
 Requires: %{_sbindir}/minicoredumper
+Requires: %{_bindir}/buxton2ctl
 
 %description
 crash-manager
index d4c0e40..f7f254d 100644 (file)
@@ -188,18 +188,14 @@ int main(int argc, char *argv[])
        INFORM_IF_ERROR(ret)
 
        if (is_root) {
-               fprintf_fd(out_fd, "\n==== System configuration (/usr/bin/vconftool get memory, db, file)\n");
-               char *get_mem_args[] = {"/bin/vconftool", "get", "memory/", "-r", NULL};
+               fprintf_fd(out_fd, "\n==== System configuration (/usr/bin/buxton2ctl dump memory, system)\n");
+               char *get_mem_args[] = {"/usr/bin/buxton2ctl", "dump", "memory", NULL};
                ret = run_command_write_fd_timeout(get_mem_args[0], get_mem_args, NULL, out_fd, NULL, 0, TIMEOUT_DEFAULT);
                INFORM_IF_ERROR(ret)
 
-               char *get_db_args[] = {"/bin/vconftool", "get", "db/", "-r", NULL};
+               char *get_db_args[] = {"/usr/bin/buxton2ctl", "dump", "system", NULL};
                ret = run_command_write_fd_timeout(get_db_args[0], get_db_args, NULL, out_fd, NULL, 0, TIMEOUT_DEFAULT);
                INFORM_IF_ERROR(ret)
-
-               char *get_file_args[] = {"/bin/vconftool", "get", "file/", "-r", NULL};
-               ret = run_command_write_fd_timeout(get_file_args[0], get_file_args, NULL, out_fd, NULL, 0, TIMEOUT_DEFAULT);
-               INFORM_IF_ERROR(ret)
        }
 
        if (arg_dmesg && is_root) {