Skip to content

Very slow fit call #972

Closed
Closed

Description

@chang-ph

I'm not sure if it is a bug, but this happens in our use case.

This runs quickly:

using StatsBase: fit, Histogram

fit(Histogram, [-5.6,-5.6])

This takes a very long time:

using StatsBase: fit, Histogram

fit(Histogram, [-5.603325961434038e29,-5.603325961434038e29])

Activity

  1. BjarkeHautop commented on Jul 15, 2026

    @BjarkeHautop
    Contributor

    I can also make it OOM:

    using StatsBase: fit, Histogram
    fit(Histogram, [-5.603325961434038e25,-5.603325961434038e25])
    #> ERROR: OutOfMemoryError()

    Created on 2026-07-15 with MinimalWorkingExamples v0.2.0 using Julia 1.12.6

    Stacktrace
    Stacktrace:
      [1] GenericMemory
        @ ./boot.jl:588 [inlined]
      [2] Array
        @ ./boot.jl:647 [inlined]
      [3] Array
        @ ./boot.jl:660 [inlined]
      [4] zeros
        @ ./array.jl:595 [inlined]
      [5] zeros
        @ ./array.jl:591 [inlined]
      [6] Histogram(edges::Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, ::Type{Int64}, closed::Symbol, isdensity::Bool)
        @ StatsBase ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:212
      [7] fit(::Type{Histogram{Int64}}, vs::Tuple{Vector{Float64}}, edges::Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}; closed::Symbol)
        @ StatsBase ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:353
      [8] fit
        @ ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:353 [inlined]
      [9] fit(::Type{Histogram{Int64}}, vs::Tuple{Vector{Float64}}; closed::Symbol, nbins::Int64)
        @ StatsBase ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:356
     [10] fit
        @ ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:356 [inlined]
     [11] fit
        @ ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:300 [inlined]
     [12] fit(::Type{Histogram}, args::Vector{Float64})
        @ StatsBase ~/.julia/packages/StatsBase/2Znv8/src/hist.jl:413
     [13] top-level scope
        @ none:1
    Environment
    Julia Version 1.12.6
    Commit 15346901f00 (2026-04-09 19:20 UTC)
    Build Info:
      Official https://julialang.org release
    Platform Info:
      OS: Linux (x86_64-linux-gnu)
      CPU: 16 × AMD Ryzen 7 8845HS w/ Radeon 780M Graphics
      WORD_SIZE: 64
      LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
      GC: Built with stock GC
    Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)
    Environment:
      JULIA_LOAD_PATH = @:@stdlib
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions