]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Speed up geom_stats_resync in the presence of many devices
authorAlan Somers <asomers@FreeBSD.org>
Sat, 27 Feb 2021 15:59:40 +0000 (08:59 -0700)
committerAlan Somers <asomers@FreeBSD.org>
Wed, 3 Mar 2021 01:33:45 +0000 (18:33 -0700)
commitab63da3564e8ab0907f9d8eb565774848ffdadeb
tree6871f9096ed113eec6aec62afb57227951a254d6
parentafb1aa4e6df245d38fd2ba683fa521d5dabe8392
Speed up geom_stats_resync in the presence of many devices

The old code had a O(n) loop, where n is the size of /dev/devstat.
Multiply that by another O(n) loop in devstat_mmap for a total of
O(n^2).

This change adds DIOCGMEDIASIZE support to /dev/devstat so userland can
quickly determine the right amount of memory to map, eliminating the
O(n) loop in userland.

This change decreases the time to run "gstat -bI0.001" with 16,384 md
devices from 29.7s to 4.2s.

Also, fix a memory leak first reported as PR 203097.

Sponsored by: Axcient
Reviewed by: mav, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28968
lib/libgeom/geom_stats.c
sys/kern/subr_devstat.c