[patch] make hal start a lot faster
Arjan van de Ven
arjan at infradead.org
Sun Jul 27 12:40:30 PDT 2008
Hal is a significant part of the boot time of (optimized) systems; so
optimizing hal to start faster is certainly worthwhile.
The patch below cuts the start time of hal by about one third,
by reducing the number of calls to hal_device_get_udi() from
well over 700.000 to below 100.000.
(why this goes via the GOT and isn't an inline is a topic for a separate conversation)
--- hal-0.5.11/hald/device_info.c.org 2008-07-27 12:30:55.000000000 -0700
+++ hal-0.5.11/hald/device_info.c 2008-07-27 12:32:10.000000000 -0700
@@ -273,22 +273,27 @@ handle_match (struct rule *rule, HalDevi
char prop_to_check[HAL_PATH_MAX];
const char *key = rule->key;
const char *value = (char *)RULES_PTR(rule->value_offset);
+ const char *d_udi;
+
+ d_udi = hal_device_get_udi (d);
/* Resolve key paths like 'someudi/foo/bar/baz:prop.name' '@prop.here.is.an.udi:with.prop.name' */
if (!resolve_udiprop_path (key,
- hal_device_get_udi (d),
+ d_udi,
udi_to_check, sizeof (udi_to_check),
prop_to_check, sizeof (prop_to_check))) {
/*HAL_ERROR (("Could not resolve keypath '%s' on udi '%s'", key, value));*/
return FALSE;
}
- d = hal_device_store_find (hald_get_gdl (), udi_to_check);
- if (d == NULL)
- d = hal_device_store_find (hald_get_tdl (), udi_to_check);
- if (d == NULL) {
- HAL_ERROR (("Could not find device with udi '%s'", udi_to_check));
- return FALSE;
+ if (strcmp(udi_to_check, d_udi)) {
+ d = hal_device_store_find (hald_get_gdl (), udi_to_check);
+ if (d == NULL)
+ d = hal_device_store_find (hald_get_tdl (), udi_to_check);
+ if (d == NULL) {
+ HAL_ERROR (("Could not find device with udi '%s'", udi_to_check));
+ return FALSE;
+ }
}
switch (rule->type_match) {
--
If you want to reach me at my work email, use arjan at linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
More information about the hal
mailing list