Speed %pyproject_save_files up significantly by using sets instead of lists
For packages with a lot of files, it took a really long time to run. Profiling the code revealed most of the time is spent in PurePath.__eq__. The code was using lists but checked if to-be-added paths were not already in them. Considering the order is insignificant (the generated %files list is sorted at the end anyway), the lists were essentially working as (very slow) sets. Using sets instead of lists makes %pyproject_save_files over 20 times faster (51.66 -> 2.39 seconds) for the ansible package (~62k files). Checking if an item is in a list is O(N), checking every added item is O(N**2). Checking if an item is in a set is O(1), checking every added item is O(N). Additionally, with set, it is unnecessary to check for presence before addition, so the code is easier. (Commit message and removal of the check by Miro.) Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
parent
3ae687d401
commit
4aaa4be87e
@ -172,6 +172,7 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
- Fixes: rhbz#2391290
|
||||
- On RPM 4.20+ don't put pyproject-macros-specific files in %%buildsubdir
|
||||
- Works around https://github.com/rpm-software-management/rpm/issues/3890
|
||||
- Speed %%pyproject_save_files up significantly
|
||||
|
||||
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.18.3-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
|
||||
|
||||
@ -137,12 +137,11 @@ def add_file_to_module(paths, module_name, module_type, files_dirs, *files):
|
||||
"""
|
||||
for module in paths["modules"][module_name]:
|
||||
if module["type"] == module_type:
|
||||
if files[0] not in module[files_dirs]:
|
||||
module[files_dirs].extend(files)
|
||||
module[files_dirs].update(files)
|
||||
break
|
||||
else:
|
||||
paths["modules"][module_name].append(
|
||||
{"type": module_type, "files": [], "dirs": [], files_dirs: list(files)}
|
||||
{"type": module_type, "files": set(), "dirs": set(), files_dirs: set(files)}
|
||||
)
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user