From 454fdaf1191c87e5c770ab865a911e10e600e178 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Mon, 7 Oct 2024 17:33:38 +0000 Subject: sync: Always use WORKER_BATCH_SIZE With 551285fa35ccd0836513e9cf64ee8d3372e5e3f4, the comment about number of workers no longer stands - dict is shared among multiprocesses and real time information is available. Using 2.7k projects as the baseline, using chunk size of 4 takes close to 5 minutes. A chunk size of 32 takes this down to 40s - a reduction of rougly 8 times which matches the increase. R=gavinmak@google.com Bug: b/371638995 Change-Id: Ida5fd8f7abc44b3b82c02aa0f7f7ae01dff5eb07 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/438523 Commit-Queue: Josip Sokcevic Tested-by: Josip Sokcevic Reviewed-by: Gavin Mak --- tests/test_subcmds_sync.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/test_subcmds_sync.py') diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py index 8dde687c..b871317c 100644 --- a/tests/test_subcmds_sync.py +++ b/tests/test_subcmds_sync.py @@ -355,6 +355,30 @@ class SafeCheckoutOrder(unittest.TestCase): ) +class Chunksize(unittest.TestCase): + """Tests for _chunksize.""" + + def test_single_project(self): + """Single project.""" + self.assertEqual(sync._chunksize(1, 1), 1) + + def test_low_project_count(self): + """Multiple projects, low number of projects to sync.""" + self.assertEqual(sync._chunksize(10, 1), 10) + self.assertEqual(sync._chunksize(10, 2), 5) + self.assertEqual(sync._chunksize(10, 4), 2) + self.assertEqual(sync._chunksize(10, 8), 1) + self.assertEqual(sync._chunksize(10, 16), 1) + + def test_high_project_count(self): + """Multiple projects, high number of projects to sync.""" + self.assertEqual(sync._chunksize(2800, 1), 32) + self.assertEqual(sync._chunksize(2800, 16), 32) + self.assertEqual(sync._chunksize(2800, 32), 32) + self.assertEqual(sync._chunksize(2800, 64), 32) + self.assertEqual(sync._chunksize(2800, 128), 21) + + class GetPreciousObjectsState(unittest.TestCase): """Tests for _GetPreciousObjectsState.""" -- cgit v1.2.3-54-g00ecf