Optimizing printing performance