The bug
The /give and /replaceitem commands are slow even when no players are found by the selector. They're especially slow when the specified item has a lot of components, even though there was nobody to even give the item to, so no item should be generated.
How to reproduce
Download and open the attached world
Pull the levers next to the command blocks (the two marked with blue concrete are the most important), one at a time
Observe the server performance for each:
The one on the left tries to give a sword to a non-existent player, 30,000 times per tick
The one on the right tries to execute as a non-existent player to give themselves a sword, 30,000 times per tick
Expected behavior
Server performance is identical
Observed behavior
Left command blocks tank the server, right slows it only a bit
The report hasn't been updated for a while. Does the issue still occurs for you in the newest version?