I've just done some troubleshooting work for a client who has a very large form (over 200 fields). It uses conditional logic to hide most fields and only reveal them upon certain input selections.
When most of the fields are filled, the form processes to completion without problem in under 60 seconds (their script timeout). However, when most of the fields are empty, the form processing blows out to about 200 seconds (tested on my dev box, 3.6GHz 64-bit multicore with 16GB RAM). I've had to up their script timeout to 300 seconds to ensure they get their form submissions.
What seems to be happening is that fields with values go through GFCommon::replace_variables() once, but fields with no values go through that loop four times. Thus, the more empty fields a form has, the worse its performance.
Time for some rocket surgery! (e.g. check for empty before iterating over GFCommon::replace_variables() four time?)
cheers,
Ross