mrkn commented on pull request #7539: URL: https://github.com/apache/arrow/pull/7539#issuecomment-652298958
I wrote a benchmark code that measures the performance of conversion from Tensor to SparseTensor. And I run this code with `--repetitions=10` and got the following result. - Converting to SparseCOOTensor is 1.4x-1.8x slower than the original. - Converting to SparseCSRMatrix and SparseCSCMatrix is 1.0x-1.2x faster than the original. - Converting to SparseCSFTensor is 1.0-1.3x slower than the original. I don't think this result, especially SparseCOOTensor's case can be acceptable. Now I'm trying to resolve this performance regression. <details> <summary><b>The full result is shown below:</b></summary> <table role="table"> <thead> <tr> <th>Format</th> <th>IndexType</th> <th>ValueType</th> <th align="right">Change %</th> <th align="right">Baseline</th> <th align="right">Contender</th> </tr> </thead> <tbody> <tr> <td>COO</td> <td>Int32Type</td> <td>Int8</td> <td align="right">56.426</td> <td align="right">2459.397090</td> <td align="right">3847.138775</td> </tr> <tr> <td>COO</td> <td>Int16Type</td> <td>Int8</td> <td align="right">43.062</td> <td align="right">2619.848028</td> <td align="right">3748.014603</td> </tr> <tr> <td>COO</td> <td>Int64Type</td> <td>Int8</td> <td align="right">40.137</td> <td align="right">2850.826136</td> <td align="right">3995.057821</td> </tr> <tr> <td>COO</td> <td>Int8Type</td> <td>Int8</td> <td align="right">35.478</td> <td align="right">2776.716694</td> <td align="right">3761.850287</td> </tr> <tr> <td>COO</td> <td>Int16Type</td> <td>Int16</td> <td align="right">66.812</td> <td align="right">2394.011928</td> <td align="right">3993.489611</td> </tr> <tr> <td>COO</td> <td>Int32Type</td> <td>Int16</td> <td align="right">59.281</td> <td align="right">2728.577337</td> <td align="right">4346.096797</td> </tr> <tr> <td>COO</td> <td>Int64Type</td> <td>Int16</td> <td align="right">52.043</td> <td align="right">2596.404005</td> <td align="right">3947.663313</td> </tr> <tr> <td>COO</td> <td>Int8Type</td> <td>Int16</td> <td align="right">44.510</td> <td align="right">2768.567992</td> <td align="right">4000.853968</td> </tr> <tr> <td>COO</td> <td>Int32Type</td> <td>Float</td> <td align="right">93.283</td> <td align="right">2287.343291</td> <td align="right">4421.039474</td> </tr> <tr> <td>COO</td> <td>Int16Type</td> <td>Float</td> <td align="right">71.100</td> <td align="right">2577.689569</td> <td align="right">4410.437858</td> </tr> <tr> <td>COO</td> <td>Int64Type</td> <td>Float</td> <td align="right">61.035</td> <td align="right">2821.300996</td> <td align="right">4543.277655</td> </tr> <tr> <td>COO</td> <td>Int8Type</td> <td>Float</td> <td align="right">53.303</td> <td align="right">2666.801559</td> <td align="right">4088.291362</td> </tr> <tr> <td>COO</td> <td>Int64Type</td> <td>Double</td> <td align="right">88.230</td> <td align="right">2616.000738</td> <td align="right">4924.096764</td> </tr> <tr> <td>COO</td> <td>Int16Type</td> <td>Double</td> <td align="right">70.188</td> <td align="right">2698.335495</td> <td align="right">4592.253023</td> </tr> <tr> <td>COO</td> <td>Int32Type</td> <td>Double</td> <td align="right">69.368</td> <td align="right">2579.753902</td> <td align="right">4369.267270</td> </tr> <tr> <td>COO</td> <td>Int8Type</td> <td>Double</td> <td align="right">62.781</td> <td align="right">2747.179806</td> <td align="right">4471.895533</td> </tr> <tr> <td>CSR</td> <td>Int8Type</td> <td>Int8</td> <td align="right">-1.660</td> <td align="right">4626.181791</td> <td align="right">4549.389657</td> </tr> <tr> <td>CSR</td> <td>Int32Type</td> <td>Int8</td> <td align="right">-4.718</td> <td align="right">4708.044556</td> <td align="right">4485.938002</td> </tr> <tr> <td>CSR</td> <td>Int64Type</td> <td>Int8</td> <td align="right">-4.905</td> <td align="right">4687.961132</td> <td align="right">4458.024004</td> </tr> <tr> <td>CSR</td> <td>Int16Type</td> <td>Int8</td> <td align="right">-7.164</td> <td align="right">4851.803479</td> <td align="right">4504.201161</td> </tr> <tr> <td>CSR</td> <td>Int32Type</td> <td>Int16</td> <td align="right">-1.481</td> <td align="right">4722.676795</td> <td align="right">4652.711030</td> </tr> <tr> <td>CSR</td> <td>Int64Type</td> <td>Int16</td> <td align="right">-5.853</td> <td align="right">4573.124314</td> <td align="right">4305.462839</td> </tr> <tr> <td>CSR</td> <td>Int8Type</td> <td>Int16</td> <td align="right">-11.890</td> <td align="right">4631.290389</td> <td align="right">4080.628990</td> </tr> <tr> <td>CSR</td> <td>Int16Type</td> <td>Int16</td> <td align="right">-12.372</td> <td align="right">4737.320600</td> <td align="right">4151.197839</td> </tr> <tr> <td>CSR</td> <td>Int64Type</td> <td>Float</td> <td align="right">-4.999</td> <td align="right">4711.575565</td> <td align="right">4476.032868</td> </tr> <tr> <td>CSR</td> <td>Int16Type</td> <td>Float</td> <td align="right">-5.062</td> <td align="right">4811.457037</td> <td align="right">4567.909440</td> </tr> <tr> <td>CSR</td> <td>Int32Type</td> <td>Float</td> <td align="right">-7.651</td> <td align="right">4814.813084</td> <td align="right">4446.432341</td> </tr> <tr> <td>CSR</td> <td>Int8Type</td> <td>Float</td> <td align="right">-12.196</td> <td align="right">5158.868330</td> <td align="right">4529.676101</td> </tr> <tr> <td>CSR</td> <td>Int32Type</td> <td>Double</td> <td align="right">0.384</td> <td align="right">4631.005506</td> <td align="right">4648.789489</td> </tr> <tr> <td>CSR</td> <td>Int64Type</td> <td>Double</td> <td align="right">-0.273</td> <td align="right">4816.669765</td> <td align="right">4803.522209</td> </tr> <tr> <td>CSR</td> <td>Int8Type</td> <td>Double</td> <td align="right">-3.453</td> <td align="right">4646.652774</td> <td align="right">4486.217718</td> </tr> <tr> <td>CSR</td> <td>Int16Type</td> <td>Double</td> <td align="right">-8.963</td> <td align="right">4952.032110</td> <td align="right">4508.161865</td> </tr> <tr> <td>CSC</td> <td>Int8Type</td> <td>Int8</td> <td align="right">-4.207</td> <td align="right">4871.793338</td> <td align="right">4666.848429</td> </tr> <tr> <td>CSC</td> <td>Int64Type</td> <td>Int8</td> <td align="right">-10.582</td> <td align="right">4571.251613</td> <td align="right">4087.509465</td> </tr> <tr> <td>CSC</td> <td>Int16Type</td> <td>Int8</td> <td align="right">-13.189</td> <td align="right">4865.666295</td> <td align="right">4223.934008</td> </tr> <tr> <td>CSC</td> <td>Int32Type</td> <td>Int8</td> <td align="right">-16.546</td> <td align="right">4999.577506</td> <td align="right">4172.360711</td> </tr> <tr> <td>CSC</td> <td>Int32Type</td> <td>Int16</td> <td align="right">-0.619</td> <td align="right">4842.515715</td> <td align="right">4812.531287</td> </tr> <tr> <td>CSC</td> <td>Int8Type</td> <td>Int16</td> <td align="right">-4.128</td> <td align="right">4689.737235</td> <td align="right">4496.135413</td> </tr> <tr> <td>CSC</td> <td>Int16Type</td> <td>Int16</td> <td align="right">-8.110</td> <td align="right">4643.413441</td> <td align="right">4266.836346</td> </tr> <tr> <td>CSC</td> <td>Int64Type</td> <td>Int16</td> <td align="right">-10.302</td> <td align="right">4971.879449</td> <td align="right">4459.696887</td> </tr> <tr> <td>CSC</td> <td>Int8Type</td> <td>Float</td> <td align="right">-0.547</td> <td align="right">4694.347970</td> <td align="right">4668.667817</td> </tr> <tr> <td>CSC</td> <td>Int32Type</td> <td>Float</td> <td align="right">-0.619</td> <td align="right">4718.207593</td> <td align="right">4688.994670</td> </tr> <tr> <td>CSC</td> <td>Int64Type</td> <td>Float</td> <td align="right">-3.360</td> <td align="right">4847.753893</td> <td align="right">4684.849545</td> </tr> <tr> <td>CSC</td> <td>Int16Type</td> <td>Float</td> <td align="right">-7.408</td> <td align="right">4956.795348</td> <td align="right">4589.607722</td> </tr> <tr> <td>CSC</td> <td>Int32Type</td> <td>Double</td> <td align="right">0.491</td> <td align="right">4917.172760</td> <td align="right">4941.321519</td> </tr> <tr> <td>CSC</td> <td>Int64Type</td> <td>Double</td> <td align="right">-0.754</td> <td align="right">5069.589290</td> <td align="right">5031.376333</td> </tr> <tr> <td>CSC</td> <td>Int16Type</td> <td>Double</td> <td align="right">-2.023</td> <td align="right">4762.425910</td> <td align="right">4666.071367</td> </tr> <tr> <td>CSC</td> <td>Int8Type</td> <td>Double</td> <td align="right">-5.987</td> <td align="right">4934.016268</td> <td align="right">4638.636384</td> </tr> <tr> <td>CSF</td> <td>Int16Type</td> <td>Int8</td> <td align="right">25.394</td> <td align="right">7885.986312</td> <td align="right">9888.571309</td> </tr> <tr> <td>CSF</td> <td>Int64Type</td> <td>Int8</td> <td align="right">22.605</td> <td align="right">9083.444559</td> <td align="right">11136.716151</td> </tr> <tr> <td>CSF</td> <td>Int32Type</td> <td>Int8</td> <td align="right">13.486</td> <td align="right">8228.377064</td> <td align="right">9338.031561</td> </tr> <tr> <td>CSF</td> <td>Int8Type</td> <td>Int8</td> <td align="right">11.900</td> <td align="right">7687.347967</td> <td align="right">8602.168534</td> </tr> <tr> <td>CSF</td> <td>Int64Type</td> <td>Int16</td> <td align="right">28.094</td> <td align="right">8247.255772</td> <td align="right">10564.280045</td> </tr> <tr> <td>CSF</td> <td>Int8Type</td> <td>Int16</td> <td align="right">20.276</td> <td align="right">8172.411486</td> <td align="right">9829.454135</td> </tr> <tr> <td>CSF</td> <td>Int32Type</td> <td>Int16</td> <td align="right">15.240</td> <td align="right">8776.213727</td> <td align="right">10113.751856</td> </tr> <tr> <td>CSF</td> <td>Int16Type</td> <td>Int16</td> <td align="right">13.707</td> <td align="right">8396.322326</td> <td align="right">9547.223214</td> </tr> <tr> <td>CSF</td> <td>Int16Type</td> <td>Float</td> <td align="right">25.989</td> <td align="right">8340.996459</td> <td align="right">10508.758442</td> </tr> <tr> <td>CSF</td> <td>Int32Type</td> <td>Float</td> <td align="right">20.562</td> <td align="right">8882.075299</td> <td align="right">10708.400993</td> </tr> <tr> <td>CSF</td> <td>Int8Type</td> <td>Float</td> <td align="right">19.021</td> <td align="right">8507.160025</td> <td align="right">10125.299339</td> </tr> <tr> <td>CSF</td> <td>Int64Type</td> <td>Float</td> <td align="right">1.769</td> <td align="right">9657.000323</td> <td align="right">9827.819671</td> </tr> <tr> <td>CSF</td> <td>Int8Type</td> <td>Double</td> <td align="right">20.382</td> <td align="right">8380.183782</td> <td align="right">10088.211026</td> </tr> <tr> <td>CSF</td> <td>Int32Type</td> <td>Double</td> <td align="right">14.353</td> <td align="right">9512.403696</td> <td align="right">10877.711426</td> </tr> <tr> <td>CSF</td> <td>Int16Type</td> <td>Double</td> <td align="right">13.737</td> <td align="right">8536.269931</td> <td align="right">9708.870939</td> </tr> <tr> <td>CSF</td> <td>Int64Type</td> <td>Double</td> <td align="right">12.413</td> <td align="right">9737.555217</td> <td align="right">10946.296736</td> </tr> </tbody> </table> </details> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org