[augeas-devel] Httpd strategy

Francis Giraldeau francis.giraldeau at usherbrooke.ca
Fri Jul 23 01:48:47 UTC 2010


Hi, 

Ok, this will be a long mail about the httpd lens. 

There is one big issue with Httpd lens: it's huge configuration space.
There are few sections names and over 200 directives. There are two
strategies: generic v.s. exact. I wanted to compare both strategies for
their runtime performance and how they were easy to use. 

Let's say we want a generic lens, a lens that matches any directives and
sections. Then, we got a put ambiguity error, because both directive and
section lenses will match a node like { /[a-zA-Z0-9]+/ }. One way to
bypass this problem is to use the following nodes 

sections:    { /[a-zA-Z0-9]+/ } 
directives:  { "#directive" = /[a-zA-Z0-9]/ }

Because "#" is not in the section name, then we avoid the put ambiguity.
The lens size is small, because we avoid to list all directives, but
notice that the directive name is a value, not a label. It's harder to
use, because of the more complex path queries involved. 

exact:   set "/VirtualHost/ServerAdmin" "some at example.com"
generic: set "/VirtualHost/*[#directive = 'ServerAdmin']/#arg"
"some at example.com"

/* I was not actualy able to make the generic set working, 
* but that should look close to that ... someone can help me on that?
*/

Now, the exact lens is about to list every possible sections and
directives names. It's better to list everything than to substract
allowed directives from a generic regexp, because resulting automatons
are much smaller. Since keys are distincts from sections and directives,
then there is no put ambiguity. 

sections:   { /VirtualHost|Directory|.../ }
directives: { /ServerAdmin|Alias|.../ }

Then, we can use simpler paths to access directives, but at the cost of
a bigger lens. 

Here are the results parsing benchmark with a representative apache
configuration for the two lenses. (average of 10 runs on intel duo
1,8GHz) First test is real time to process the test and the second is
total memory allocation reported by valgrind. 

               | time w check  | time wo check 
Httpd_exact    | 5,31 s        | 0,34 s
Httpd_generic  | 0,09 s        | 0,05 s

               | mem w check   | mem wo check 
Httpd_exact    | 1536 Mb       | 61 Mb
Httpd_generic  |    3 Mb       |  1 Mb


Huge differences. There is a cost to get this lens easy to use. We have
to choose which one, because after that people will start to write code
for it and it will be a bit harder to change. Is it acceptable, for
users, to wait few hundred milliseconds more to load lenses? There is
also another point to take into consideration. Httpd directives are case
insensitive, the generic lens handle this and the exact one doesn't. 

Every files are availables on square2 branch on github (look for
httpd_exact.aug and httpd_generic.aug). 

http://github.com/giraldeau/augeas/tree/square2

Cheer, 

Francis




More information about the augeas-devel mailing list