summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-hashserv
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2019-09-17 08:37:11 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-18 17:52:01 +0100
commit20f032338ff3b4b25f2cbb7f975b5fd1c105004d (patch)
tree84c1a4693fdbaac0823e99d70ed7c814b890244c /bitbake/bin/bitbake-hashserv
parent34923e4f772fc57c29421741d2f622eb4009961c (diff)
downloadpoky-20f032338ff3b4b25f2cbb7f975b5fd1c105004d.tar.gz
bitbake: bitbake: Rework hash equivalence
Reworks the hash equivalence server to address performance issues that were encountered with the REST mechanism used previously, particularly during the heavy request load encountered during signature generation. Notable changes are: 1) The server protocol is no longer HTTP based. Instead, it uses a simpler JSON over a streaming protocol link. This protocol has much lower overhead than HTTP since it eliminates the HTTP headers. 2) The hash equivalence server can either bind to a TCP port, or a Unix domain socket. Unix domain sockets are more efficient for local communication, and so are preferred if the user enables hash equivalence only for the local build. The arguments to the 'bitbake-hashserve' command have been updated accordingly. 3) The value to which BB_HASHSERVE should be set to enable a local hash equivalence server is changed to "auto" instead of "localhost:0". The latter didn't make sense when the local server was using a Unix domain socket. 4) Clients are expected to keep a persistent connection to the server instead of creating a new connection each time a request is made for optimal performance. 5) Most of the client logic has been moved to the hashserve module in bitbake. This makes it easier to share the client code. 6) A new bitbake command has been added called 'bitbake-hashclient'. This command can be used to query a hash equivalence server, including fetching the statistics and running a performance stress test. 7) The table indexes in the SQLite database have been updated to optimize hash lookups. This change is backward compatible, as the database will delete the old indexes first if they exist. 8) The server has been reworked to use python async to maximize performance with persistently connected clients. This requires Python 3.5 or later. (Bitbake rev: 2124eec3a5830afe8e07ffb6f2a0df6a417ac973) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin/bitbake-hashserv')
-rwxr-xr-xbitbake/bin/bitbake-hashserv24
1 files changed, 15 insertions, 9 deletions
diff --git a/bitbake/bin/bitbake-hashserv b/bitbake/bin/bitbake-hashserv
index 6c911c098a..1bc1f91f38 100755
--- a/bitbake/bin/bitbake-hashserv
+++ b/bitbake/bin/bitbake-hashserv
@@ -11,20 +11,26 @@ import logging
11import argparse 11import argparse
12import sqlite3 12import sqlite3
13 13
14sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib')) 14sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
15 15
16import hashserv 16import hashserv
17 17
18VERSION = "1.0.0" 18VERSION = "1.0.0"
19 19
20DEFAULT_HOST = '' 20DEFAULT_BIND = 'unix://./hashserve.sock'
21DEFAULT_PORT = 8686 21
22 22
23def main(): 23def main():
24 parser = argparse.ArgumentParser(description='HTTP Equivalence Reference Server. Version=%s' % VERSION) 24 parser = argparse.ArgumentParser(description='Hash Equivalence Reference Server. Version=%s' % VERSION,
25 parser.add_argument('--address', default=DEFAULT_HOST, help='Bind address (default "%(default)s")') 25 epilog='''The bind address is the path to a unix domain socket if it is
26 parser.add_argument('--port', type=int, default=DEFAULT_PORT, help='Bind port (default %(default)d)') 26 prefixed with "unix://". Otherwise, it is an IP address
27 parser.add_argument('--prefix', default='', help='HTTP path prefix (default "%(default)s")') 27 and port in form ADDRESS:PORT. To bind to all addresses, leave
28 the ADDRESS empty, e.g. "--bind :8686". To bind to a specific
29 IPv6 address, enclose the address in "[]", e.g.
30 "--bind [::1]:8686"'''
31 )
32
33 parser.add_argument('--bind', default=DEFAULT_BIND, help='Bind address (default "%(default)s")')
28 parser.add_argument('--database', default='./hashserv.db', help='Database file (default "%(default)s")') 34 parser.add_argument('--database', default='./hashserv.db', help='Database file (default "%(default)s")')
29 parser.add_argument('--log', default='WARNING', help='Set logging level') 35 parser.add_argument('--log', default='WARNING', help='Set logging level')
30 36
@@ -41,10 +47,11 @@ def main():
41 console.setLevel(level) 47 console.setLevel(level)
42 logger.addHandler(console) 48 logger.addHandler(console)
43 49
44 server = hashserv.create_server((args.address, args.port), args.database, args.prefix) 50 server = hashserv.create_server(args.bind, args.database)
45 server.serve_forever() 51 server.serve_forever()
46 return 0 52 return 0
47 53
54
48if __name__ == '__main__': 55if __name__ == '__main__':
49 try: 56 try:
50 ret = main() 57 ret = main()
@@ -53,4 +60,3 @@ if __name__ == '__main__':
53 import traceback 60 import traceback
54 traceback.print_exc() 61 traceback.print_exc()
55 sys.exit(ret) 62 sys.exit(ret)
56