JuliaArrays / JuliaArrays/StructArrays.jl

Extreme slowdown in IndexedTable creation with CategoricalArrays

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
402
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Hello, after a discussion with @piever , he suggested I open an issue with StructArrays. A recent update to CategoricalArrays has created an extreme slowdown of the IndexedTables/JuliaDB table() function. The full details of that conversation can be found on this open issue posted on JuliaDB.

The short version is (with a MWE):

using JuliaDB, BenchmarkTools, CategoricalArrays

function tabletest()
    names = fill.(["red","blue","green"], 150000) |> Base.Iterators.flatten |> collect
    loci = "loc".*string.(collect(1:1500))
    loci = fill.(loci, 300) |> Base.Iterators.flatten |> collect
    genotypes = fill((1,2), 450000)

    return table((names = names, loci = loci, genotypes = genotypes), pkey = :names)
end

function tabletest_cat()
    names = fill.(["red","blue","green"], 150000) |> Base.Iterators.flatten |> collect
    loci = "loc".*string.(collect(1:1500))
    loci = fill.(loci, 300) |> Base.Iterators.flatten |> collect
    genotypes = fill((1,2), 450000)

    return table(
            (names = categorical(names, compress = true), 
            loci = categorical(loci, compress = true), 
            genotypes = genotypes),
            pkey = :names
        )
end
julia> @benchmark tabletest()
BenchmarkTools.Trial: 
  memory estimate:  79.81 MiB
  allocs estimate:  900109
  --------------
  minimum time:     246.040 ms (7.45% GC)
  median time:      270.271 ms (12.39% GC)
  mean time:        280.085 ms (15.80% GC)
  maximum time:     436.054 ms (44.68% GC)
  --------------
  samples:          18
  evals/sample:     1

Howerver, doing @benchmark tabletest_cat() has been running for several hours and hadn't finished by the time I killed the job, which is probably not a good sign.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided tabletest() and tabletest_cat() benchmarks with JuliaDB, BenchmarkTools, and CategoricalArrays. Read the table() path in StructArrays and the linked JuliaDB issue to understand how categorical columns are handled. Done means categorical table creation completes without the reported extreme slowdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
databases, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.