diff options
author | Elliott Hughes <enh@google.com> | 2015-08-03 10:38:08 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-08-24 11:15:01 -0700 |
commit | aa2454919098ee14cd232669f1e7dbb33ed07ccf (patch) | |
tree | 5f246c9585696c2ef826493b5a80c98a05bc0947 /adb/file_sync_service.h | |
parent | 28595721b19791cf4c857f048acdaeae632d329e (diff) | |
download | system_core-aa2454919098ee14cd232669f1e7dbb33ed07ccf.tar.gz system_core-aa2454919098ee14cd232669f1e7dbb33ed07ccf.tar.bz2 system_core-aa2454919098ee14cd232669f1e7dbb33ed07ccf.zip |
adb sync cleanup.
We can double the speed of "adb sync" (on N9) if we increase SYNC_DATA_MAX
from 64KiB to 256KiB. This change doesn't do that, because I still haven't
managed to plumb through the information about whether we're a new adb/adbd
to file_sync_client.cpp and file_sync_service.cpp. But this is already a big
change with a lot of cleanup, so let's do the cleanup and worry about the
intended change another day...
This change does improve performance somewhat by halving the number of
lstat(2) calls made on the client side, and ensuring that most packets are
sent with a single write. This has the pleasing result of making the null
sync on an AOSP N9 go from just over 300ms to around 100ms, which means it
now seems instantaneous (https://en.wikipedia.org/wiki/Mental_chronometry).
Change-Id: If9f6d4c1f93ec752b95f71211bbbb1c513045166
Diffstat (limited to 'adb/file_sync_service.h')
-rw-r--r-- | adb/file_sync_service.h | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/adb/file_sync_service.h b/adb/file_sync_service.h index 1d3e3bd97..c0df075f5 100644 --- a/adb/file_sync_service.h +++ b/adb/file_sync_service.h @@ -26,7 +26,6 @@ #define ID_STAT MKID('S','T','A','T') #define ID_LIST MKID('L','I','S','T') -#define ID_ULNK MKID('U','L','N','K') #define ID_SEND MKID('S','E','N','D') #define ID_RECV MKID('R','E','C','V') #define ID_DENT MKID('D','E','N','T') @@ -36,41 +35,41 @@ #define ID_FAIL MKID('F','A','I','L') #define ID_QUIT MKID('Q','U','I','T') +struct SyncRequest { + uint32_t id; // ID_STAT, et cetera. + uint32_t path_length; // <= 1024 + // Followed by 'path_length' bytes of path (not NUL-terminated). +} __attribute__((packed)) ; + union syncmsg { - unsigned id; - struct { - unsigned id; - unsigned namelen; - } req; - struct { + struct __attribute__((packed)) { unsigned id; unsigned mode; unsigned size; unsigned time; } stat; - struct { + struct __attribute__((packed)) { unsigned id; unsigned mode; unsigned size; unsigned time; unsigned namelen; } dent; - struct { + struct __attribute__((packed)) { unsigned id; unsigned size; } data; - struct { + struct __attribute__((packed)) { unsigned id; unsigned msglen; } status; -} ; - +}; -void file_sync_service(int fd, void *cookie); -int do_sync_ls(const char *path); -int do_sync_push(const char *lpath, const char *rpath, bool show_progress); -int do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only); -int do_sync_pull(const char *rpath, const char *lpath, bool show_progress, int pullTime); +void file_sync_service(int fd, void* cookie); +bool do_sync_ls(const char* path); +bool do_sync_push(const char* lpath, const char* rpath, bool show_progress); +bool do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only); +bool do_sync_pull(const char* rpath, const char* lpath, bool show_progress, int copy_attrs); #define SYNC_DATA_MAX (64*1024) |