Info
Index builds limit their memory usage with the parameter maxIndexBuildMemoryUsageMegabytes, which defaults to 500MB. The memory usage calculation depends on the BSONObj accurately reporting its memory usuage in memUsageForSorter().
BSONObj reports its memory usage as the size of the object, but not the capacity of the buffer holding that object. This is problematic because index builds can use significantly more memory than they they should.
We should change the imlementation of memUsageForSorter() to report the size of the underlying SharedBuffer, in a very similar way to what we did for in SERVER-42931.
Top User Comments
xgen-internal-githook commented on Mon, 23 Dec 2019 22:59:42 +0000:
Author:
{'name': 'Eric Milkie', 'email': 'milkie@mongodb.com', 'username': 'milkie'}
Message: SERVER-44964 calculate index build memory usage per key based on BSONObj buffer capacity instead of object size
Branch: v4.2
https://github.com/mongodb/mongo/commit/38e05a18e716da5020d8f01f37e8bd8cf8f769b1