=rem #16428 optimize protobuf serializer for master

#16428 for master
thank you.akka's code style is very nice,maybe I like to match just cause I am following the best scala code style from akka. ：P
In fact in the previous version of this PR.I don't check the CAS,and only one level tailrec,but @viktorklang  said that will loosing cache.