Skip to content

Slow weighted sum/dot etc. #775

Description

@DNF2

dot(w, x), sum(x, w) etc. seem to use a slow fallback implementation of dot:

1.7.2> using StatsBase

1.7.2> x = rand(1000); w = weights(rand(length(x)));

1.7.2> x = rand(1000); w = weights(rand(1000));

1.7.2> @btime dot($w, $x)
  975.000 ns (0 allocations: 0 bytes)
244.6881117358608

1.7.2> @btime dot($w.values, $x)
  85.151 ns (0 allocations: 0 bytes)
244.68811173586084

The same goes for calling sum(x, w) or wsum(x, w).

This is independent of the number of BLAS threads.

This is a pretty dramatic performance difference. Should StatsBase call BLAS.dot or is this something that should be improved in the fallback dot routine in Base?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions