The comment here is not correct: https://github.com/emacs-mirror/emacs/blob/2a6af880b0958d527a4d32005ef9acf3bc4ea030/lisp/net/tramp-sh.el#L3736-L3740

The command file-directory-p should also be cached.  Fortunately, the result is already cached so all that is needed is to add this function to the list.  Performance of the ssh commands for vc-register is improved by 170% with this patch.

It's described in detail here: https://github.com/emacs-mirror/emacs/pull/43

How can I help get this patch into the repository?

Eyal