I'm currently working on understanding the performance of snapshot restores in my company's test suite. I've read a lot of material online about how the time it takes to perform a restore is directly proportional to the size of the snapshot - that is, the number of pages that have been copied to the snapshot sparse file. I've mostly found this to be true, and it's an intuitive conclusion. However, there does appear to be a "floor" performance that you hit when the snapshot is sufficiently small. I haven't seen this discussed anywhere, and I don't quite understand it.
Essentially, what I've found is that the size of the snapshot does NOT have a linear relationship to the time taken to restore the snapshot. Instead, as snapshot size approaches zero, restore time approaches about 3.5 seconds. I'm sure this floor is a bit different depending on your setup, but both on my local dev machine and on the dozens of build servers we've studied, we have not been able to reduce the restore time of a snapshot below around three and a half seconds.
I've spent the last day running a local test to help illustrate this phenomenon. I performed the test by creating a fresh database containing a single table with a single integer valued column. I created a snapshot of the database when it was empty, then filled the table and restored the snapshot, using SSMS client statistics to measure how long the restore operation took. I graphed the restore time in milliseconds against the number of rows in the table when restore was called:
Notably, when there is nothing to restore, the restore time is a relatively constant .15-.3s. That's the 0 on the X axis here. But as soon as we have even just one row to restore, the time goes up to a little over 3 seconds. I have other data that shows this phenomenon on our build servers - its not local to my machine, so it must have something to do with the implementation of snapshot restore. But I can't find anything explaining this phenomenon online, anywhere. Can anyone help me understand it? Is this something that only affects me? Is it possible to increase the performance of snapshot restores past this limit? Any help is appreciated - thanks!