Skip to content

Commit

Permalink
[SYSTEMDS-3805] Minor performance improvement scalar right indexing
Browse files Browse the repository at this point in the history
For operations like as.scalar(data[i,1]), we now use a fast path which
improved the performance for 10M iterations as follows:

  1  rightIndex     5.513  10000000 (old)
  1  rightIndex     4.717  10000000 (new)

This is generally useful also for cases where there is no as.scalar.
However, for the case as.scalar(data[i,1]) we should directly compile
a new rixScalar instruction which look up the value, avoids matrixblock
allocation, and gets rid of unnecessary createvar, cast, and rmvar
instructions.
  • Loading branch information
mboehm7 committed Dec 10, 2024
1 parent 0242557 commit 716d5ce
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ public void processInstruction(ExecutionContext ec) {

if( mo.isPartitioned() ) //via data partitioning
resultBlock = mo.readMatrixPartition(ixrange.add(1));
else if( ixrange.isScalar() ){
MatrixBlock matBlock = mo.acquireReadAndRelease();
resultBlock = new MatrixBlock(
matBlock.get((int)ixrange.rowStart, (int)ixrange.colStart));
}
else //via slicing the in-memory matrix
{
//execute right indexing operation (with shallow row copies for range
//of entire sparse rows, which is safe due to copy on update)
MatrixBlock matBlock = ec.getMatrixInput(input1.getName());
MatrixBlock matBlock = mo.acquireRead();
resultBlock = matBlock.slice((int)ixrange.rowStart, (int)ixrange.rowEnd,
(int)ixrange.colStart, (int)ixrange.colEnd, false, new MatrixBlock());

Expand Down

0 comments on commit 716d5ce

Please sign in to comment.