On Fri, Mar 12, 2010 at 2:15 AM, David Lutterkort <[email protected]> wrote: > On Wed, 2010-03-10 at 16:25 +0100, Frederik Wagner wrote: >> On Wed, Mar 10, 2010 at 9:46 AM, Frederik Wagner <[email protected]> >> wrote: >> > 2. Would there be a way to inlcude the 'string' array handling into >> > the shellvars lens? Probably only by handling specific entries of >> > specific files (how do I test for the scanned file in a lens?) >> > diferently, I suppose? >> >> As a (working) test I included the functionality into the shellvars >> lens to treat specific keywords as an array of words. >> This works fine (even if one has to keep an explicit list of keywords >> which have to be treated in this way), but for the fact that the >> [email protected] >> is _incredibly_ slow now and using a _lot_ of memory. > > Where are you seeing the slowdown ? With augtool or augparse ?
in both. It is due to the this line: let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export" - key_wa each additional word which is 'substracted' (so each additional word in "key_wa"), it becomes slower, using up more and more memory (an makes my poor old laptop swap like mad) I do not find a way around this construct... > Generally, these kinds of lenses cause the typechecker to work very hard > - the typechecker is only run by augparse. You can bypass it with > 'augparse --notypecheck'; though before declaring any changes 'done', > you need to typecheck the lens at least once. > >> To filter or the keywords I'm using - just showing the relevant adjustments: >> >> ... >> (* keywords from files which should be treaded as array of words *) >> let key_wa = >> (* from /etc/sysconfig/kernel *) >> "MODULES_LOADED_ON_BOOT" >> | "DOMU_INITRD_MODULES" >> | "INITRD_MODULES" >> (* from /etc/sysconfig/bootloader *) >> | "DEFAULT_APPEND" >> | "FAILSAFE_APPEND" >> | "XEN_KERNEL_APPEND" >> | "XEN_APPEND" >> | "RT_APPEND" >> >> let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export" - key_wa >> ... >> >> and later in the lens I'm applying extras steps to the filtered keywords: >> >> ... >> let char_wa = /[^ "\t\n]/ >> >> (* for the keywords in key_wa treat the values as an array of words *) >> let wa_array = f >> let wa_array_value = store char_wa+ in >> del /\"[ \t]*/ "\"" . counter "wa_val" . >> [ seq "wa_val" .wa_array_value ] . >> [ del /[ \t\n]+/ " " . seq "wa_val" . wa_array_value ] * >> . del /[ \t]*\"/ "\"" >> >> (* lens for the array of words, extra handling of empty strings "" *) >> let wa_kv = [ key key_wa . eq . (del "\"\"" "\"\""|wa_array) . eol ] >> >> let lns = ( comment | empty | source | kv | unset | wa_kv ) * >> ... >> >> Since I change the fast working original shellvars lens, I suppose the >> filtering construct is the problem. >> >> Am I doing something wrong? Or is the adjustment of the shellvars lens >> generally not usefull anyway? (if it is I would submit the patch, when >> I'm ready). > > Another way to structure this is to make the current lens 'lns' a > function that takes the special variables as an argument, so that you'd > have > > let wa (keys:regexp) = > ( comment | empty | source | kv | unset | wa_kv keys) * > > and change wa_kv to pass keys respectively (key_re - key_wa) to the > right parts of the lens. > I don't completely understand what you mean by 'the right parts of the lens', but this does not solve the problem above, does it? > Then, write separate transforms and filters for each file, e.g. > > let kernel_xfm = > let wa_keys = /MODULES_LOADED_ON_BOOT|DOMU_INITRD_MODULES|INITRD_MODULES/ > in > transform (wa wa_keys) (incl "/etc/sysconfig/kernel") > > There's one minor hitch though: Augeas right now only allows one > autoload statement per module. That will force you to have separate may I ask, what does the autoload stand for? (xfm?) > modules for each file that you want to handle that way, e.g. > > module Shellvars_kernel = > autoload xfm > > let lns = Shellvars.wa > /MODULES_LOADED_ON_BOOT|DOMU_INITRD_MODULES|INITRD_MODULES/ > let xfm = transform lns (incl "/etc/sysconfig/kernel") this would not be the worst thing :-) Bye, Frederik _______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
