Though they had developed pyrotechnics, the question as to whether the 9th c. Chinese had guns, let alone a sizing system, is at least debatable.
The earliest standardization of bore sizes seems to have come about in Spain, a part of the firearms development that occurred under Charles V in the midst of the Italian Wars. My sources are translated into English, so I am not sure what would be the original Spanish for "ounce", but military matchlock arquebuses bore sizes were in terms of the balls they shot- in 1535 a contract was issued for some using balls of 3/4 ounce and one-half silver real in weight . It was also specified that all the guns be the same bore, so that they could shoot the same size ball. This was important for military weapons, where ammunition would be made in large quantities for whole armies. But because bullet molds would be supplied to go with an order of guns, you also find contracts that are rather vague; in the 17th c. , there was a very diverse terminology, so English carbines circa 1690 were short guns, dragons, musquettoones, bastard carbines, short bastard snaphannce musquetts, or musquetts for dragoons.... and sometimes simply specified as "carbine bore" or " musquett bore". But by the late 16th c. the English were also using "caliber" for bore : they could also order guns of the "same caliber". The word was essentially the same as "caliper", and so a synonym for diameter. Cannon could be described as having barrels " of 20 calibers", where a 4 inch bore would be 80 inches long.
Guns could often be ordered in inch measurements by at least the 18th c. George Washington ordered a fowler ( shotgun) from England with "5/8 inch bore". I am not quite sure precisely when people began to make caliber to mean the same as inch, where ".45 calber" means, now, .45 inches ( or does NOT mean .45 inches...it has become, notoriously, mostly used as just a part of a trade name: .357 Magnum and .38 Special bullets are the same diameter, but .44 Colt and .44 Smith and Wesson bullets are not). I suspect that it was commonly adopted when un-patched conical bullets and then breech-loaders and metallic cartridges became common. But despite the fact that a bullet's weight ceased to be dependent on the diameter, that older system of defining the bore by bullet weight continued into the 19th c.- a British hunter would talk about his "4 bore" muzzle-loading elephant gun. And it exists still to this day- if a 12 gauge shotgun were shooting round balls, each would be 1/12 of a pound.