Merge "ui: Improve ui-dev-server latency"
diff --git a/tools/dev_server b/tools/dev_server
index 7188f38..bd74df7 100755
--- a/tools/dev_server
+++ b/tools/dev_server
@@ -20,6 +20,7 @@
import argparse
import socket
import subprocess
+import threading
try:
import socketserver
@@ -43,6 +44,7 @@
self.port = port
self.directory = directory
self.rebuilder = rebuilder
+ self.lock = threading.Lock()
def serve(self):
this = self
@@ -60,7 +62,8 @@
def do_GET(self):
try:
- this.rebuilder.rebuild_if_needed()
+ with this.lock:
+ this.rebuilder.rebuild_if_needed()
except RebuildFailed as e:
self.send_response(200)
self.send_header("Content-type", "text/html")
@@ -90,6 +93,7 @@
self.command = command
self.ignored_paths = ignored_paths
self.last_disk_state = None
+ self.abs_ignored_paths = [os.path.abspath(p) for p in self.ignored_paths]
def rebuild_if_needed(self):
if self.last_disk_state == self.last_modified_time():
@@ -103,7 +107,8 @@
def last_modified_time(self):
start_time = time.time()
max_mtime = 0
- for dirpath, dirnames, filenames in os.walk('.', topdown=True):
+ for dirpath, dirnames, filenames in os.walk(
+ os.path.abspath('.'), topdown=True):
dirnames[:] = [
n for n in dirnames
if not self.should_ignore_path(os.path.join(dirpath, n))
@@ -119,8 +124,7 @@
return max_mtime
def should_ignore_path(self, path):
- return os.path.abspath(path) in (
- os.path.abspath(p) for p in self.ignored_paths)
+ return path in self.abs_ignored_paths
def rebuild(self):
print('Running command: {}'.format(self.command))
diff --git a/ui/run-dev-server b/ui/run-dev-server
index 11a602e..9faf567 100755
--- a/ui/run-dev-server
+++ b/ui/run-dev-server
@@ -39,6 +39,7 @@
-i $ROOT_DIR/src/traced \
-i $ROOT_DIR/buildtools \
-i $ROOT_DIR/out \
+ -i $ROOT_DIR/infra \
-i $ROOT_DIR/ui/node_modules \
-s $UI_OUT_DIR \
"$ROOT_DIR/tools/ninja -C $OUT_DIR ui"