Conceptually, I think of this as the volatility of a portfolio with a -100% position in the benchmark. Then you can just add a row and column to the portfolio's co-variance matrix.
$Tracking Variance = \sum \sum w_i w_j \sigma_i \sigma_j \rho_{i,j} + \sigma^2_{bench} + 2\sum w_i (w_{bench} = -1)\sigma_i \sigma_{bench}\rho_{i,bench}$
Taking the first derivative with respect to some $w_*$:
$\Delta Tracking Variance = 2(w_*\sigma^2_*+ \sum_{i\not= *} w_i \sigma_i \sigma_* \rho_{i,*} - \sigma_* \sigma_{bench}\rho_{*,bench})$