[ https://issues.apache.org/jira/browse/MAHOUT-1837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15270352#comment-15270352 ]
ASF GitHub Bot commented on MAHOUT-1837:
----------------------------------------
Github user andrewpalumbo commented on the pull request:
https://github.com/apache/mahout/pull/228#issuecomment-216799830
Performance comparison:
We can see some speedups though also some performance hits. The performance hits are likely due to the sampling and testing of the data, rather than just the examination of the matrix structure, and at first glance seems to be somewhat constant.
Performance gains are significant in some places will try to examine more closely later.
There is also likely something to gain by tuning the parameters of the `isMatrixDense(...)` function.
Master
-
```
Ad %*% Bd: (231.66666666666666,51.0)
Ad(::,::) %*% Bd: (288.0,33.0)
Ad' %*% Bd: (440.6666666666667,35.666666666666664)
Ad %*% Bd': (168.0,38.666666666666664)
Ad' %*% Bd': (300.6666666666667,37.333333333333336)
Ad'' %*% Bd'': (276.3333333333333,35.666666666666664)
Asr %*% Bsr: (47.666666666666664,24.333333333333332)
Asr' %*% Bsr: (1200.3333333333333,20.0)
Asr %*% Bsr': (119.0,22.0)
Asr' %*% Bsr': (1000.0,16.666666666666668)
Asr'' %*% Bsr'': (15.666666666666666,18.666666666666668)
Asm %*% Bsm: (1228.3333333333333,27.333333333333332)
Asm' %*% Bsm: (1633.6666666666667,29.333333333333332)
Asm %*% Bsm': (1021.3333333333334,34.333333333333336)
Asm' %*% Bsm': (1367.6666666666667,17.666666666666668)
Asm'' %*% Bsm'': (1314.6666666666667,17.0)
Asm %*% Bsr: (1049.6666666666667,18.333333333333332)
Asm' %*% Bsr: (1507.3333333333333,23.333333333333332)
Asm %*% Bsr': (957.3333333333334,20.666666666666668)
Asm' %*% Bsr': (1401.0,16.333333333333332)
Asm'' %*% Bsr'': (1051.3333333333333,17.333333333333332)
Asr %*% Bsm: (18.333333333333332,20.333333333333332)
Asr' %*% Bsm: (1610.3333333333333,21.666666666666668)
Asr %*% Bsm': (118.33333333333333,26.333333333333332)
Asr' %*% Bsm': (1306.0,18.0)
Asr'' %*% Bsm'': (18.0,17.666666666666668)
Ad %*% Bsr: (701.0,66.0)
Ad' %*% Bsr: (900.0,52.333333333333336)
Ad %*% Bsr': (620.0,50.0)
Ad' %*% Bsr': (819.0,49.666666666666664)
Ad'' %*% Bsr'': (711.0,55.333333333333336)
Asr %*% Bd: (54.333333333333336,50.0)
Asr' %*% Bd: (707.0,53.666666666666664)
Asr %*% Bd': (112.33333333333333,74.66666666666667)
Asr' %*% Bd': (779.3333333333334,80.0)
Asr'' %*% Bd'': (63.666666666666664,71.33333333333333)
Ad %*% Bsm: (964.3333333333334,172.33333333333334)
Ad' %*% Bsm: (1183.0,171.66666666666666)
Ad %*% Bsm': (704.0,175.0)
Ad' %*% Bsm': (891.6666666666666,77.33333333333333)
Ad'' %*% Bsm'': (952.6666666666666,172.0)
Asm %*% Bd: (514.6666666666666,72.33333333333333)
Asm' %*% Bd: (814.3333333333334,77.0)
Asm %*% Bd': (541.6666666666666,73.33333333333333)
Asm' %*% Bd': (842.6666666666666,165.0)
Asm'' %*% Bd'': (507.3333333333333,71.0)
Ad %*% D: (213.0,13.666666666666666)
Asr %*% D: (57.333333333333336,19.333333333333332)
Asm %*% D: (378.6666666666667,15.0)
D %*% Ad: (10.333333333333334,2.6666666666666665)
D %*% Asr: (8.0,2.0)
D %*% Asm: (1.0,1.3333333333333333)
Ad' %*% D: (409.3333333333333,2.6666666666666665)
Asr' %*% D: (571.0,1.3333333333333333)
Asm' %*% D: (658.3333333333334,1.3333333333333333)
D %*% Ad': (13.666666666666666,5.666666666666667)
D %*% Asr': (16.333333333333332,6.333333333333333)
D %*% Asm': (10.333333333333334,6.333333333333333)
```
This Branch
-
```
Ad %*% Bd: (193.33333333333334,55.666666666666664)
Ad(::,::) %*% Bd: (272.0,53.333333333333336)
Ad' %*% Bd: (438.0,40.666666666666664)
Ad %*% Bd': (169.0,32.333333333333336)
Ad' %*% Bd': (291.6666666666667,33.333333333333336)
Ad'' %*% Bd'': (230.0,41.666666666666664)
Asr %*% Bsr: (42.333333333333336,31.666666666666668)
Asr' %*% Bsr: (1183.6666666666667,24.0)
Asr %*% Bsr': (98.0,23.333333333333332)
Asr' %*% Bsr': (993.3333333333334,21.333333333333332)
Asr'' %*% Bsr'': (15.666666666666666,22.666666666666668)
Asm %*% Bsm: (1267.6666666666667,23.333333333333332)
Asm' %*% Bsm: (1635.3333333333333,25.666666666666668)
Asm %*% Bsm': (1012.3333333333334,24.333333333333332)
Asm' %*% Bsm': (1428.3333333333333,19.0)
Asm'' %*% Bsm'': (1254.6666666666667,29.333333333333332)
Asm %*% Bsr: (1037.6666666666667,17.333333333333332)
Asm' %*% Bsr: (1480.6666666666667,22.666666666666668)
Asm %*% Bsr': (954.0,20.666666666666668)
Asm' %*% Bsr': (1383.3333333333333,25.666666666666668)
Asm'' %*% Bsr'': (1034.6666666666667,16.666666666666668)
Asr %*% Bsm: (17.666666666666668,17.0)
Asr' %*% Bsm: (1563.3333333333333,25.333333333333332)
Asr %*% Bsm': (111.66666666666667,24.0)
Asr' %*% Bsm': (1271.3333333333333,19.333333333333332)
Asr'' %*% Bsm'': (17.0,23.333333333333332)
Ad %*% Bsr: (692.3333333333334,61.666666666666664)
Ad' %*% Bsr: (875.6666666666666,49.0)
Ad %*% Bsr': (623.6666666666666,54.333333333333336)
Ad' %*% Bsr': (795.0,48.333333333333336)
Ad'' %*% Bsr'': (693.0,50.0)
Asr %*% Bd: (55.0,47.666666666666664)
Asr' %*% Bd: (681.3333333333334,49.0)
Asr %*% Bd': (110.0,66.33333333333333)
Asr' %*% Bd': (758.6666666666666,74.0)
Asr'' %*% Bd'': (59.666666666666664,59.0)
Ad %*% Bsm: (940.3333333333334,173.0)
Ad' %*% Bsm: (1164.0,174.33333333333334)
Ad %*% Bsm': (698.6666666666666,168.33333333333334)
Ad' %*% Bsm': (881.3333333333334,65.66666666666667)
Ad'' %*% Bsm'': (939.3333333333334,162.0)
Asm %*% Bd: (527.3333333333334,60.666666666666664)
Asm' %*% Bd: (808.3333333333334,66.66666666666667)
Asm %*% Bd': (577.6666666666666,62.333333333333336)
Asm' %*% Bd': (870.6666666666666,166.66666666666666)
Asm'' %*% Bd'': (512.0,61.0)
Ad %*% D: (229.66666666666666,14.333333333333334)
Asr %*% D: (52.666666666666664,19.666666666666668)
Asm %*% D: (429.3333333333333,14.666666666666666)
D %*% Ad: (8.666666666666666,2.3333333333333335)
D %*% Asr: (6.333333333333333,1.6666666666666667)
D %*% Asm: (1.0,1.3333333333333333)
Ad' %*% D: (437.0,4.333333333333333)
Asr' %*% D: (570.3333333333334,2.0)
Asm' %*% D: (664.6666666666666,2.3333333333333335)
D %*% Ad': (13.666666666666666,7.0)
D %*% Asr': (19.666666666666668,5.666666666666667)
D %*% Asm': (10.333333333333334,7.0)
```
Post by Andrew Palumbo (JIRA)Sparse/Dense Matrix analysis for Matrix Multiplication
------------------------------------------------------
Key: MAHOUT-1837
URL: https://issues.apache.org/jira/browse/MAHOUT-1837
Project: Mahout
Issue Type: Improvement
Components: Math
Affects Versions: 0.12.0
Reporter: Andrew Palumbo
Assignee: Andrew Palumbo
Fix For: 0.12.1
In matrix multiplication, Sparse Matrices can easily turn dense and bloat memory, one fully dense column and one fully dense row can cause a sparse %*% sparse operation have a dense result.
{code}
val comb = if (block.getFlavor == MatrixFlavor.SPARSELIKE) {
new SparseMatrix(prodNCol, block.nrow).t
} else {
new DenseMatrix(prodNCol, block.nrow).t
}
{code}
a simlar check needs to be made in the {{blockify}} transformation.
# More importantly, and more involved is to do an actual analysis of the resulting matrix data in the in-core {{mmul}} class and use a matrix of the appropriate Structure as a result.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)