  We prove pointwise and $L^{p}$-gradient comparison results for solutions to
elliptic Dirichlet problems defined on open subsets of a (possibly non-smooth)
space with positive Ricci curvature (more precisely of an $\mathrm{RCD}(K,N)$
metric measure space, with $K>0$ and $N\in (1,\infty)$). The obtained
Talenti-type comparison is sharp, rigid and stable with respect to
$L^{2}$/measured-Gromov-Hausdorff topology; moreover, several aspects seem new
even for smooth Riemannian manifolds. As applications of such Talenti-type
comparison, we prove a series of improved Sobolev-type inequalities, and an
$\mathrm{RCD}$ version of the St.~Venant-P\'olya torsional rigidity comparison
theorem (with associated rigidity and stability statements). Finally, we give a
probabilistic interpretation (in the setting of smooth Riemannian manifolds) of
the aforementioned comparison results, in terms of exit time from an open
subset for the Brownian motion.
