On Tue, 18 Dec 2012, James Pearson wrote:
Towards the end, you mention moving a rule from being of the form

   if ((a || b ) && c) {

to

        if (a || b) {
                if (c) {

, where c is an expensive check and (a || b) rules out most pages, and seeing a
CPU usage decrease.  This seems odd to me, since I'd expect short-circuiting to
cut out the check for c if (a || b) is false.

In reality what I did was closer to changing:

if ((a || b ) && c) { }
if ((a || b ) && d) { }
if ((a || b ) && e) { }

to:

if (a || b) {
  if (c) { }
  if (d) { }
  if (e) { }
}

where c,d & e were large regex functions. The test ( a || b ) was matched about 14% of the time.

I don't think I would see as large a drop in CPU usage if "c" wasn't being checked in the original code when even when (a || b) failed.


--
Simon Lyall  |  Very Busy  |  Web: http://www.darkmere.gen.nz/
"To stay awake all night adds a day to your life" - Stilgar | eMT.


_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to