TempDB is shared amongst all the databases on the instance. So there can sometimes be contention within TempDB for certain pages: SGAM, GAM, and PFS. In a nutshell, these pages keep track of what's been used in TempDB so far, and where space is available for new use.
Typically, this is dealt with by adding multiple data files to TempDB. There are a few different philosophies as to the correct number, but all agree you should have more than one.
Here are a few queries to run...
This one will show you how many files TempDB has and where they are located.
-- tempdb layout
use tempdb
go
exec sp_helpfile
go
This one will show you how many CPUs and cores you have.
-- cores and hyperthreading
select cpu_count, hyperthread_ratio
from sys.dm_os_sys_info
go
This one will show you how many NUMA nodes and cores per NUMA node you have.
-- numa nodes and schedulers
select node_id, online_scheduler_count
from sys.dm_os_nodes
order by node_id
go
This one will show you which pages are experiencing waits in TempDB.
-- see if anything is waiting on tempdb
select *
from sys.dm_os_waiting_tasks
where resource_description like '2:%'
go
Here is an article which goes into a bit more depth on the page contention issue.
OK, so now the philosophy part... :-)
For myself, if I am on an SMP system, I only want as many files as half the total cores.
If I am on a NUMA system, then I only want as many files as cores per NUMA node.
However, I rarely see any improvement for having more that four files for TempDB. So I usually start with four and monitor contention as explained in the article I linked to.
If I continue to see problems, then I would add two more. Check again, add more, and repeat until the contention disappears.