Adapter permission lookup is quite expensive, here we avoid looking up permissions for all adapters and instead search only one we need.
On empty phabricator instance (couple of users, projects) - this reduces *each* personal herald rule execution from 1.5ms to 0.3ms for Maniphest tasks.
For our production case it was reducing runtime from 20ms to 2-3ms for each Personal herald rule... We have large user base and some large projects.
This also reduces runtime for Personal Herald rules touching other objects, like differential...
On my personal resource limited RasberryPI alike server (4x1.2ghz ARM A53, 2GB ram, php 7.4.12) running Phabricator - this changes saves ~15ms of runtime (180ms vs 167ms after) when running:
./bin/herald test --object T19 --type HeraldManiphestTaskAdapter
It is pretty empty instance - 19 tasks, 1 user and 1 personal Herald rule...