Assume that \(X\) and \(Y\) are locally compact and locally doubling metric spaces, which are also generalized \(n\)-manifolds, that \(X\) is locally linearly locally \(n\)-connected, and that \(Y\) has bounded turning. In this paper, addressing Heinonen's ICM 02 talk, we study the geometry of the branch set \(\mathcal{B}_f\) of a quasiregular mapping between metric \(n\)-manifolds. In particular, we show that \(\mathcal{B}_f\cap \{x\in X:H_f(x)<\infty\}\) is countably porous, as is its image \(f\big(\mathcal{B}_f\cap \{x\in X:H_f(x)<\infty\}\big)\). As a corollary, \(\mathcal{B}_f\cap \{x\in X:H_f(x)<\infty\}\) and its image are null sets with respect to any locally doubling measures on \(X\) and Y, respectively. Moreover, if either \(H_f(x)\leq H\) or \(H_f^*(x)\leq H^*\) for all \(x\in X\), then both \(\mathcal{B}_f\) and \(f\big(\mathcal{B}_f\big)\) are countably \(\delta\)-porous, quantitatively, with a computable porosity constant. When further metric and analytic assumptions are placed on \(X\), \(Y\), and \(f\), our theorems generalize the well-known Bonk--Heinonen theorem and Sarvas' theorem to a large class of metric spaces. Moreover, our results are optimal in terms of the underlying geometric structures. As a direct application, we obtain the important V\"ais\"al\"a's inequality in greatest generality. Applying our main results to special cases, we solve an open problem of Heinonen--Rickman and an open question of Heinonen--Semmes.