It does not add 1.8s to every DNS query: If there is an entry in the DNS cache, and that entry has expired (despite prefetch) for less than 1 day, it allows the (upstream) DNS query to take up to 1.8s, before it serves the expired entry from the cache. But usually, upstream queries are a lot faster. A quick test here took 0.030s for a fresh DNS query, and 0.001s for the same afterwards, as it has been stored in the cache. So upstream is usually still 1-2 magnitude of orders faster than this 1.8s fallback. And for new queries, or such where the cache entry expired for more than serve-expired-ttl: (1 day), Unbound does and always did allow the upstream query to take unlimited time.
Yes, the RFC-compliant serve-expired mode reduces the cache hit rate, but reduces the chance/risk that outdated DNS responses are sent. This is the tradeoff, and we chose to follow Unbound defaults for higher reliability, instead of restoring pre-1.23 defaults for a little cache hit rate gain that most users will still never recognize. prefetch is still enabled to reduce the chance that regularly called DNS queries expire in the first place.
If you want to max out the cache hit rate, you can set serve-expired-client-timeout: 0 of course, or even better, raise cache-min-ttl, which plays very well with prefetch as of the relatively small 10% window.
In my home adguard home having multiple upstream one is unbound.
What for do you use Unbound if you allow other upstreams aside of it? Also note that AdGuard Home as well as Pi-hole (dnsmasq) have their own DNS cache, so Unbound has no real purpose if it is not used for privacy to skip upstream providers, or use upstream DoT.
Sure, performance is not really a commonly intended goal of using Unbound. It is a recursive resolver, hence may do multiple queries from DNS root servers to final authoritative name servers, then does DNSSEC on top. Public DNS providers naturally can do that a lot faster, and keep every DNS query in cache with thousands/millions of requests to each of them each second. Of course with a local DNS cache, you can still be faster, but Iād usually rate reliability/accuracy of the response higher than whether it is some centiseconds faster, at least when it is about defaults for software that is commonly used for privacy purpose, not for maxing out DNS performance.
What we could do is exposing the serve-expired-client-timeout: commented out in our config, adding some lines that explain what it does, notably the effect of setting it to 0, to always serve cache entries expired since up to a day, instead querying upstream first.