summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-21 19:31:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-24 21:59:44 +0000
commit663c259ffa3b013cb7cc3f4e1dc69aca917706b2 (patch)
treed828d1a205d688dad358f1864e57905460ac80bd /bitbake/lib/bb/tests
parent72072db00465595293eda7b9b5446fcabef6552a (diff)
downloadpoky-663c259ffa3b013cb7cc3f4e1dc69aca917706b2.tar.gz
bitbake: data: Add support for new BB_HASH_CODEPARSER_VALS for cache optimisation
Currently the codeparser cache ends up being extended for every parse run since there are values in the functions such as the result of os.getpid() from LOGFIFO in OE-Core. Digging into that issue, there are also lots of similar but different functions being parsed where the change might just be a path to WORKDIR, a change in PN or PV or something like DATE/TIME. There is no reason we have to use these changing values when computing the dependenies of the functions. Even with a small tweak like: BB_HASH_CODEPARSER_VALS = "LOGFIFO=/ T=/ WORKDIR=/ DATE=1234 TIME=1234 PV=0.0-1 PN=nopn" the cache is reduced from ~4.6MB, increasing by ~300kb for every parse run to around 1.3MB and remaining static for oe-core and meta-oe. In my local build, admittedly heavily experimented with, the cache had grown to 120MB. The benefits of doing this are: * faster load time for bitbake since the cache is smaller to read from disk and load into memory * being able to skip saving the cache upon shutdown * lower memory footprint for bitbake * faster codeparser data lookups (since there is less data to search) We only use these special values when passing code fragments to the codeparser to parse so the real variable values should otherwise be used in the hash data. The overall effect of this change, combined with others to avoid saving unchanged cache files can be ~2s on a ~16s parse on my local system and results in a more responsive feeling bitbake. It also allows parsing performance to be investigated more consistently. (Bitbake rev: f24bbaaddb36f479a59a958e7fc90ef454c19473) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/codeparser.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/bitbake/lib/bb/tests/codeparser.py b/bitbake/lib/bb/tests/codeparser.py
index a508f23bcb..7f5d59ca74 100644
--- a/bitbake/lib/bb/tests/codeparser.py
+++ b/bitbake/lib/bb/tests/codeparser.py
@@ -318,7 +318,7 @@ d.getVar(a(), False)
318 "filename": "example.bb", 318 "filename": "example.bb",
319 }) 319 })
320 320
321 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d) 321 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
322 322
323 self.assertEqual(deps, set(["somevar", "bar", "something", "inexpand", "test", "test2", "a"])) 323 self.assertEqual(deps, set(["somevar", "bar", "something", "inexpand", "test", "test2", "a"]))
324 324
@@ -365,7 +365,7 @@ esac
365 self.d.setVarFlags("FOO", {"func": True}) 365 self.d.setVarFlags("FOO", {"func": True})
366 self.setEmptyVars(execs) 366 self.setEmptyVars(execs)
367 367
368 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d) 368 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
369 369
370 self.assertEqual(deps, set(["somevar", "inverted"] + execs)) 370 self.assertEqual(deps, set(["somevar", "inverted"] + execs))
371 371
@@ -375,7 +375,7 @@ esac
375 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo") 375 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo")
376 self.d.setVarFlag("FOO", "vardeps", "oe_libinstall") 376 self.d.setVarFlag("FOO", "vardeps", "oe_libinstall")
377 377
378 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d) 378 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
379 379
380 self.assertEqual(deps, set(["oe_libinstall"])) 380 self.assertEqual(deps, set(["oe_libinstall"]))
381 381
@@ -384,7 +384,7 @@ esac
384 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo") 384 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo")
385 self.d.setVarFlag("FOO", "vardeps", "${@'oe_libinstall'}") 385 self.d.setVarFlag("FOO", "vardeps", "${@'oe_libinstall'}")
386 386
387 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d) 387 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
388 388
389 self.assertEqual(deps, set(["oe_libinstall"])) 389 self.assertEqual(deps, set(["oe_libinstall"]))
390 390
@@ -399,7 +399,7 @@ esac
399 # Check dependencies 399 # Check dependencies
400 self.d.setVar('ANOTHERVAR', expr) 400 self.d.setVar('ANOTHERVAR', expr)
401 self.d.setVar('TESTVAR', 'anothervalue testval testval2') 401 self.d.setVar('TESTVAR', 'anothervalue testval testval2')
402 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(), self.d) 402 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
403 self.assertEqual(sorted(values.splitlines()), 403 self.assertEqual(sorted(values.splitlines()),
404 sorted([expr, 404 sorted([expr,
405 'TESTVAR{anothervalue} = Set', 405 'TESTVAR{anothervalue} = Set',
@@ -418,14 +418,14 @@ esac
418 self.d.setVar('ANOTHERVAR', varval) 418 self.d.setVar('ANOTHERVAR', varval)
419 self.d.setVar('TESTVAR', 'anothervalue testval testval2') 419 self.d.setVar('TESTVAR', 'anothervalue testval testval2')
420 self.d.setVar('TESTVAR2', 'testval3') 420 self.d.setVar('TESTVAR2', 'testval3')
421 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(["TESTVAR"]), self.d) 421 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(["TESTVAR"]), self.d, self.d)
422 self.assertEqual(sorted(values.splitlines()), sorted([varval])) 422 self.assertEqual(sorted(values.splitlines()), sorted([varval]))
423 self.assertEqual(deps, set(["TESTVAR2"])) 423 self.assertEqual(deps, set(["TESTVAR2"]))
424 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue']) 424 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue'])
425 425
426 # Check the vardepsexclude flag is handled by contains functionality 426 # Check the vardepsexclude flag is handled by contains functionality
427 self.d.setVarFlag('ANOTHERVAR', 'vardepsexclude', 'TESTVAR') 427 self.d.setVarFlag('ANOTHERVAR', 'vardepsexclude', 'TESTVAR')
428 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(), self.d) 428 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), set(), self.d, self.d)
429 self.assertEqual(sorted(values.splitlines()), sorted([varval])) 429 self.assertEqual(sorted(values.splitlines()), sorted([varval]))
430 self.assertEqual(deps, set(["TESTVAR2"])) 430 self.assertEqual(deps, set(["TESTVAR2"]))
431 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue']) 431 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue'])