Backport #30796 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
just a step towards #25655 and some related refactoring
Replace #20480 Replace #18448 Close #16414