kernel->hardware sync operations are fairly expensive in CPU cycles, and the
mechansims that add routes/neighbors to the kernel can stretch these operations
out over time.  Especially in the case of large route table updates, the full
extent of the modifications can take many seconds to make their way from the
routing protocol into the kernel.

In the interest of leaving CPU resources free to figure out the right end state,
we have coalescing of the sync operations.  The algorithm is pretty simple and
is based on an AIMD algorithm much like TCP congestion avoidance.

Each time that the kernel tables are modified, we increment a counter,
routes4_coalesce.  Each we are free to sync the tables, we evaluate this
counter... if it's not 0, we divide it by a "reducer", sync_coalesce_reducer.
If the counter reaches zero, then we initiate a kernel->hardware synchronization.

The good news here is that, if the system is not heavily taxed, the reducer will
be called more often (it's workload based as opposed to time based), thus we see
very low latency for small operations.

To avoid waiting around forever, there is a timeout, sync_coalesce_timeout, that
unconditionally initiates a pending synchronization operation.  The timer is
started when the first indication of new information is noticed.

switchd command line options exist for controling the coalescer...

-c sets sync_coalesce_reducer which defaults to 2; a value of 0 disable coalescing
-C sets sync_coalesce_timout which defaults to 10 (seconds)

For clarity, the algorithm is defined by the following python-like pseudo-code....

while true:
    if new_work:
        if routes4_coalesce == 0:
            routes4_coalesce_timer = now
        routes4_coalesce++
    if routes4_coalesce:
        if (sync_coalesce_reducer == 0) or
	   (routes4_coalesce == 0) or
           ((now - routes4_coalesce_timer) >= sync_coalesce_timeout):
            sync_kernel_to_hardware
            routes4_coalesce == 0
        else:
            routes4_coalesce /= sync_coalesce_reducer

            
