I've been looking into the math side of things a little on this, at least for the purpose of understanding the relationships between the variables at play;
-The size of the gas port puts a limit on how much mass of gas (supersonic fluid) can pass through at a given pressure
-The total mass of gas that can pass through the gas port before the bullet exits and the flow stops due to dropping pressure determines how much energy the system has to work with
-At the point gas is entering the port, chamber pressure is falling rapidly, so rate of gas pouring through it falls even faster (because the gas system is equalizing the pressure differential at the same time)
-Bolt operation time is related to barrel length (the longer gas system takes longer to operate, since the pressure in the larger volume responds slower)
-The gap between muzzle and gas port is related to gas system length* (slower bolt operation combined with lower pressure at the port means the chamber must remain pressurized much longer, even while the bullet is traveling to the muzzle faster)
-The reaction of the carrier/piston to the pressure must be slow enough to allow the bullet to exit (I suspect the pressure driving the bolt carrier is nearly done before it even moves the bolt lugs, its accumulated momentum completing the cycle)
-The total volume of the gas system must be low enough that the set volume of gas we have to work with does not depressurize excessively while its force is still needed (or it needs proper venting/volume if there is too much gas, like those pig-tail tubes or a vented self-regulating gas block like a G36)
-In the unique case of an AR, the gas tube is so small that it effectively restricts and slows down the flow of gas down its length, so bends and length can be used to tune the system a bit. I imagine pushing this technique too far can burst gas tubes or lead to fouling, though.
-While a system can be designed to be overgassed if there is enough gas volume to work with (no shortage of it in 5.56 or larger), you can't change the timing very much by restricting the gas port without dropping the mass of gas below what can fill the system properly --it won't pressurize and actuate as fast when choked, but also won't gain the needed momentum to cycle the action
What it seems to come down to, is there is likely a non-linear formula for a given chamber pressure curve (a load/chambering) that will tell you what gas system length you need for a given barrel length, and vice versa. This assumes everything else in the system is the same, but we of course have weighted buffers, lightweight bolt carriers, gas block, key, and tube designs, and port sizes. So the key is to copy something similar that works, drop one variable (like gas port size or tube length) below what is likely to work, and sweep upward until the system is sufficiently reliable (or you run out of room on that variable)
FWIW, apparently some guy made a DI 5.7x28 upper using a pistol length gas system, and another made a DI 9mm with the gas port a mere 7/8" forward of the barrel nut. Not sure where the latter would rank on that chart I posted. The main takeaway from the chart for me was how great the disparity of operating pressures (read: force) the systems have, and how rapidly they change towards the short end --that means things get finicky or dangerous really fast the closer to the chamber you get.
TCB