David's perf patches