Recently I was investigating the performance of an application we have built at https://www.swis.nl/?utm_source=barry. Now that the solution has been merged and released, here is an explanation of the performance issue and how to avoid such an issue in your own projects.
Any slowness in this process can quickly become a performance bottleneck for the complete application. The method that caused slow performance is concerned with filtering the collection of permissions.
Thanks to https://github.com/andrubeldie for pointing out the performance issues so they could be investigated and remedied.