Fixed a resource accounting performance regression in the Master.

Review: https://reviews.apache.org/r/26392