Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions dracut-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,12 @@ dracut_need_initqueue() {
# attempt to install any programs specified in a udev rule
_inst_rule_programs() {
local _prog _bin
local -A _rule_bins=()

# cache installed rule programs
if ! declare -p _rule_programs_cache 2> /dev/null | grep -q "declare -A"; then
declare -gxA _rule_programs_cache=()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am +1 for calling inst_multiple once, I am not sure about the added cache.

How much difference does this cache make? Could we do the caching in inst_multiple instead? I would go one step further for #1419: Add staging functions similar to the inst_* functions. These functions would just collect what should be added. Then call an dracut-intsall equivalent to only write a manifest for 3cpio.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am +1 for calling inst_multiple once, I am not sure about the added cache.

How much difference does this cache make?

I don't think hyperfine can show a real improvement with these kinds of minor performance patches. That depends on multiple factors. But IMO it seems like a logical and small code improvement. I remember when I implemented 80f2caf, I didn't see anything important with hyperfine, but that turned out to be critical in some systems (https://bugzilla.redhat.com/show_bug.cgi?id=2278534#c8).

Could we do the caching in inst_multiple instead? I would go one step further for #1419: Add staging functions similar to the inst_* functions. These functions would just collect what should be added. Then call an dracut-intsall equivalent to only write a manifest for 3cpio.

This is a simple, localized performance improvement. I know you would like to improve how the inst* functions work, but that would be another story. You would need to track the name of the module and all the specific options passed to dracut-install for each call, to be able to say "this module cannot be installed because...".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had very slow dracut-install executions on some ARM systems. So reducing the amount of calls we do to dracut-install helped there. That difference could be measured by hyperfine back then. So maybe I should do my benchmarks on a Raspberry Pi instead. I did the hyperfine benchmark to see if we should include this patch in the upcoming Ubuntu 26.04.

fi

# shellcheck disable=SC2013
for _prog in $(sed -nr 's/.*PROGRAM==?"([^ "]+).*/\1/p' "$1"); do
Expand All @@ -1215,7 +1221,10 @@ _inst_rule_programs() {
}
fi

[[ $_bin ]] && inst_binary "$_bin"
if [[ $_bin ]] && [[ ${_rule_bins[$_bin]:-} != 1 ]] && [[ ${_rule_programs_cache[$_bin]:-} != 1 ]]; then
_rule_bins[$_bin]=1
_rule_programs_cache[$_bin]=1
fi
done

# shellcheck disable=SC2013
Expand All @@ -1230,7 +1239,10 @@ _inst_rule_programs() {
}
fi

[[ $_bin ]] && inst_binary "$_bin"
if [[ $_bin ]] && [[ ${_rule_bins[$_bin]:-} != 1 ]] && [[ ${_rule_programs_cache[$_bin]:-} != 1 ]]; then
_rule_bins[$_bin]=1
_rule_programs_cache[$_bin]=1
fi
done

# shellcheck disable=SC2013
Expand All @@ -1245,8 +1257,13 @@ _inst_rule_programs() {
}
fi

[[ $_bin ]] && inst_multiple "$_bin"
if [[ $_bin ]] && [[ ${_rule_bins[$_bin]:-} != 1 ]] && [[ ${_rule_programs_cache[$_bin]:-} != 1 ]]; then
_rule_bins[$_bin]=1
_rule_programs_cache[$_bin]=1
fi
done

((${#_rule_bins[@]} > 0)) && inst_multiple "${!_rule_bins[@]}"
}

# attempt to create any groups and users specified in a udev rule
Expand Down
Loading