According to the performance test in https://issues.apache.org/jira/browse/SPARK-31783, the performance gain is mainly related to the nnz of block.
So it maybe reasonable to control the size of block by memory usage, instead of number of rows.
note1: param blockSize had already used in ALS and MLP to stack vectors (expected to be dense);
note2: we may refer to the Strategy.maxMemoryInMB in tree models;
There may be two ways to impl:
1, compute the sparsity of input vectors ahead of train (this can be computed with other statistics computation, maybe no extra pass), and infer a reasonable number of vectors to stack;
2, stack the input vectors adaptively, by monitoring the memory usage in a block;