The experiment with DeclarativeResponse (which is similar to the static Response attached to an URL in Bun) is a very potent performance boost for those specific cases where the feature is applicable (basically hello world cases).
The performance boost can be insane, 6x or even 20x. Because no JavaScript is called.
However, this interface is shit (and so is the Bun interface!). It requires a static-only URL handler and is a separate interface from the main one. For instance, Bun with a lambda that returns a new Response performs 20x worse than just attaching the Response directly to the route without the lambda. That distinction is easy to miss and makes no sense from a business logic perspective (they conceptually are the same).
Bringing back the CachedApp feature, finishing it, and removing DeclarativeResponse would streamline a single, dynamic interface that works with any arbitrary business logic, while having the same performance boost based on URL matches with the cache.
It is far more elegant of an interface to have arbitrary business code simply cached with a single extra (optional) argument for how long.
Here is one example: if you would use CachedApp for the HttpArea benchmarks, all of the tests (except the async delay one), would run entirely without calling any JS in the hot path. The entire thing, with all its custom logic, would be served from cache entirely by core uWS only.
That's a far more applicable performance boost than DeclarativeResponse and to some degree it is valid even for benchmarks. In fact, many real world apps could actually use this feature. Yes, you can pretty much achieve the same with a caching proxy, but having this feature part of the core, easily applicable to lots of benchmarks is a huge win for performance claims.
TLDR;
Removing the DeclarativeResponse and adding a proper CachedApp feature where you just attach an extra argument seconds to signify maximum cache duration for a route (default is zero) - is probably the lowest hanging fruit to really maximize demonstrable performance. Node.js will continue to fuck with performance, but having a CachedApp can entirely eliminate their impact on benchmarks and make even uWS.js hit those crazy numbers in benchmarks.
Also, I genuinely would need such a feature myself for actual apps. The CachedApp was already benchmarked and worked beautifully, but it introduced some C++ templating incompatibilties that I had to revert. Making this change for a v21 could allow some of those incompatibilities.
I'm just thinking out loud, but I want this.
The experiment with
DeclarativeResponse(which is similar to thestatic Response attached to an URL in Bun) is a very potent performance boost for those specific cases where the feature is applicable (basically hello world cases).The performance boost can be insane, 6x or even 20x. Because no JavaScript is called.
However, this
interface is shit(and so is the Bun interface!). It requires a static-only URL handler and is aseparate interfacefrom the main one. For instance, Bun with a lambda that returns a new Response performs 20x worse than just attaching the Response directly to the route without the lambda. That distinction is easy to miss and makes no sense from a business logic perspective (they conceptually are the same).Bringing back the CachedApp feature, finishing it, and removing DeclarativeResponse would streamline a single, dynamic interface that works with any arbitrary business logic, while having the same performance boost based on URL matches with the cache.
It is far more elegant of an interface to have arbitrary business code simply cached with a single extra (optional) argument for how long.
Here is one example: if you would use CachedApp for the HttpArea benchmarks, all of the tests (except the async delay one), would run entirely without calling any JS in the hot path. The entire thing, with all its custom logic, would be served from cache entirely by core uWS only.
That's a far more applicable performance boost than DeclarativeResponse and to some degree it is valid even for benchmarks. In fact, many real world apps could actually use this feature. Yes, you can pretty much achieve the same with a caching proxy, but having this feature part of the core, easily applicable to lots of benchmarks is a huge win for performance claims.
TLDR;
Removing the DeclarativeResponse and adding a proper CachedApp feature where you just attach an extra argument
secondsto signify maximum cache duration for a route (default is zero) - is probably thelowest hanging fruit to really maximize demonstrable performance. Node.js will continue to fuck with performance, but having a CachedApp can entirely eliminate their impact on benchmarks and make even uWS.js hit those crazy numbers in benchmarks.Also, I genuinely would need such a feature myself for actual apps. The CachedApp was already benchmarked and worked beautifully, but it introduced some C++ templating incompatibilties that I had to revert. Making this change for a v21 could allow some of those incompatibilities.
I'm just thinking out loud, but I want this.