Data retention is executed by SQL Agent scheduled job:
The job is scheduled to run every 1 hour, 20 seconds past full hour to avoid increased workload at full minute/hour.
The job executes the retention stored procedure:
Setting up retention will vary depending on the version. In older versions retention period in days was being passed directly into the procedure:
execute [dbo].[sp_sql_perf_mon_retention] @retention_period_days = 14
As of September 2018, a new configuration table was introduced to hold different snapshot types and retention values: