Not this ️
With one exception: the official “smart lighting” smart app is allowed to run locally on the hub itself, but only if all of the device types are official device types limited to some specific devices.
So that lets out both the custom code and the custom device type.
There has been much discussion for a very long time about allowing community created code to run locally, and supposedly they keep looking into it, but under the present architecture anything which could run locally has to be pushed out to every customer on the system in a firmware update, and they just don’t want to get into that.
So there is definitely a bit of additional lag. And it definitely varies not just from person to person, but from day to day and hour to an hour.
As far as UDP, SmartThings continues to tell us officially that this protocol is not supported. What is expected to be a two-way communication will be a one-way, and results can be different than what you would expect if protocol were supported. See the Milight forum topics for more discussion of this issue. It’s another one of those “one day, someday,” feature requests for now. However, you can certainly try it and see if what you get is good enough for your particular needs.