Meta: Optimized lint-ports.py by avoiding duplicate execs of package.sh

The way that lint-ports.py obtains the ports properties is unfortunately
very process intensive. You have to execute `./package.sh showproperty`
once for each property, for each port. Resulting in hundreds of
executions.

We were doing this work twice in both `check_package_files()` and in
`read_port_dirs()`. This resulted in a runtime of around ~10 seconds on
my machine. Removing the duplicate work and allowing the other code path
to utilize the to use the cached properties brought the runtime down to
~5 seconds on my machine.
This commit is contained in:
Brian Gianforcaro 2022-01-17 00:52:42 -08:00 committed by Andreas Kling
parent 4b2bbe6a7e
commit d20c5da0da
Notes: sideshowbarker 2024-07-17 20:43:22 +09:00

View File

@ -221,13 +221,11 @@ def check_package_files(ports):
"""
all_good = True
for port in ports:
for port in ports.keys():
package_file = f"{port}/package.sh"
if not os.path.exists(package_file):
continue
props = get_port_properties(port)
props = ports[port]
if not props['auth_type'] in ('sha256', 'sig', ''):
print(f"Ports/{port} uses invalid signature algorithm '{props['auth_type']}' for 'auth_type'")
all_good = False
@ -469,7 +467,7 @@ def run():
for port in sorted(ports_set - from_table_set):
print(f" {port}")
if not check_package_files(ports.keys()):
if not check_package_files(ports):
all_good = False
if not check_available_ports(from_table, ports):