Skip to content

[SYSTEMDS-3975] Sparse transpose performance [WIP] - #2640

Draft
anuunchin wants to merge 2 commits into
apache:mainfrom
anuunchin:SYSTEMDS-3975-transpose-sweep
Draft

anuunchin wants to merge 2 commits into
apache:mainfrom
anuunchin:SYSTEMDS-3975-transpose-sweep

Conversation

@anuunchin

Copy link
Copy Markdown
Contributor

Under 🚧

  1. Microbenchmark results for the local transpose (LibMatrixReorg.transpose, k=1, 1000² and 3000²) reproduce the issue that dense to sparse is consistently slower than dense to dense for sparsity 0.1–0.4, by up to 11×.
Full results (CSV)
mode,rows,cols,sparsity,nnz,k,in_sparse,out_sparse,median_ms,mean_ms,min_ms
DENSE_DENSE,1000,1000,5.01e-01,500516,1,false,false,1.5116,1.5121,1.4079
DENSE_SPARSE,1000,1000,5.01e-01,500516,1,false,true,12.6053,12.7536,11.7057
DENSE_DENSE,1000,1000,4.00e-01,400314,1,false,false,0.9792,1.0185,0.8599
DENSE_SPARSE,1000,1000,4.00e-01,400314,1,false,true,10.9990,11.0851,10.5670
DENSE_DENSE,1000,1000,2.99e-01,298893,1,false,false,0.8801,0.9084,0.8567
DENSE_SPARSE,1000,1000,2.99e-01,298893,1,false,true,9.8487,9.8146,9.0025
DENSE_DENSE,1000,1000,1.99e-01,199133,1,false,false,0.8428,0.8538,0.8270
DENSE_SPARSE,1000,1000,1.99e-01,199133,1,false,true,7.6691,7.6145,7.1275
DENSE_DENSE,1000,1000,9.93e-02,99284,1,false,false,1.5115,1.5224,1.4412
DENSE_SPARSE,1000,1000,9.93e-02,99284,1,false,true,5.7135,5.9046,5.4618
DENSE_DENSE,1000,1000,4.96e-02,49631,1,false,false,0.8569,0.8671,0.8409
DENSE_SPARSE,1000,1000,4.96e-02,49631,1,false,true,4.7245,4.7859,4.6443
DENSE_DENSE,1000,1000,9.86e-03,9860,1,false,false,1.2661,1.1738,0.9130
DENSE_SPARSE,1000,1000,9.86e-03,9860,1,false,true,4.0033,4.0082,3.9400
DENSE_DENSE,1000,1000,9.75e-04,975,1,false,false,1.8708,2.1651,1.6457
DENSE_SPARSE,1000,1000,9.75e-04,975,1,false,true,3.7576,3.7642,3.7290
DENSE_DENSE,1000,1000,8.30e-05,83,1,false,false,1.8984,2.0149,1.6658
DENSE_SPARSE,1000,1000,8.30e-05,83,1,false,true,3.7776,3.8098,3.7351
DENSE_DENSE,3000,3000,5.00e-01,4500270,1,false,false,34.4214,35.8928,18.4978
DENSE_SPARSE,3000,3000,5.00e-01,4500270,1,false,true,149.9794,153.6820,133.3542
DENSE_DENSE,3000,3000,4.00e-01,3598570,1,false,false,35.8151,39.5458,24.3300
DENSE_SPARSE,3000,3000,4.00e-01,3598570,1,false,true,143.4538,145.3179,129.4147
DENSE_DENSE,3000,3000,3.00e-01,2698633,1,false,false,45.4597,48.6977,26.6509
DENSE_SPARSE,3000,3000,3.00e-01,2698633,1,false,true,102.7453,105.5449,96.5096
DENSE_DENSE,3000,3000,2.00e-01,1798268,1,false,false,49.5517,52.5341,26.6802
DENSE_SPARSE,3000,3000,2.00e-01,1798268,1,false,true,87.8468,90.1907,83.5343
DENSE_DENSE,3000,3000,1.00e-01,899662,1,false,false,48.9996,48.8061,29.9554
DENSE_SPARSE,3000,3000,1.00e-01,899662,1,false,true,63.8740,66.9504,60.7963
DENSE_DENSE,3000,3000,5.01e-02,450586,1,false,false,47.2860,44.6252,28.8715
DENSE_SPARSE,3000,3000,5.01e-02,450586,1,false,true,50.1583,53.5134,46.1947
DENSE_DENSE,3000,3000,9.96e-03,89613,1,false,false,36.5647,37.9898,23.6043
DENSE_SPARSE,3000,3000,9.96e-03,89613,1,false,true,38.1793,38.5483,37.2683
DENSE_DENSE,3000,3000,9.90e-04,8913,1,false,false,23.9150,25.3610,17.2930
DENSE_SPARSE,3000,3000,9.90e-04,8913,1,false,true,35.7515,36.7804,34.6759
DENSE_DENSE,3000,3000,9.61e-05,865,1,false,false,14.8208,16.2591,12.8829
DENSE_SPARSE,3000,3000,9.61e-05,865,1,false,true,34.8968,35.0984,34.2587

@sincu1

sincu1 commented Nov 26, 2026

Copy link
Copy Markdown

Adding SPARSE_DENSE shows that sparse to dense is the fastest mode across low to moderate densities (sparsity < 0.3-0.4), as it only iterates over non zeros without sparse output allocation overhead. At the densest points (0.4-0.5), DENSE_DENSE remains competitive or faster, while DENSE_SPARSE is slowest overall and only outperforms DENSE_DENSE on the sparsest 3000x3000 inputs.
Running multi-threaded (k=-1) speeds up all modes on 3000x3000, whereas 1000x1000 sees almost no gain and DENSE_SPARSE slows down due to threading overhead. DENSE_SPARSE remains noticeably slower than both dense-output modes at moderate to high densities.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants