Performance improvements and instrumentation to profile threads