Skip to content

Performance regression comparing universal polynomial rings after PR #2028 #2064

@fingolfin

Description

@fingolfin

@karlwessel made the following comment on PR #2028 after it was merged:

But while this improves performance for UnivPoly{Rational{BigInt}}, performance for UnivPoly{QQFieldElem} has decreased by a lot:

julia> using Nemo

Welcome to Nemo version 0.49.1

Nemo comes with absolutely no warranty whatsoever

julia> R = universal_polynomial_ring(QQ)
Universal Polynomial Ring over Rational field

julia> xs200 = gen.(Ref(R), [Symbol("x$i") for i in 1:200])
200-element Vector{AbstractAlgebra.Generic.UnivPoly{QQFieldElem}}:
 x1
 x2
 x3
 x4
 x5
 x6
 x7
 x8
 x9
 x10
 x11
 x12
 x13
 
 x188
 x189
 x190
 x191
 x192
 x193
 x194
 x195
 x196
 x197
 x198
 x199
 x200

julia> y = gen(R, :y)
y

julia> using BenchmarkTools

julia> @benchmark xs200[end] == y
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):  342.801 μs  727.543 μs  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     343.088 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   353.182 μs ±  31.159 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █ ▄▂▃▂  ▅▄▁                                                   ▁
  █▅█████████▇▇██▆▆▆▅▄▅▅▆▅▄▁▄▅▄▅▅▃▄▃▃▄▁▄▁▃▃▃▁▁▁▃▁▃▄▁▁▃▄▁▁▃▁▁▄▃▅ █
  343 μs        Histogram: log(frequency) by time        544 μs <

 Memory estimate: 0 bytes, allocs estimate: 0.

For reference, the same MWE without this PR:

julia> using Nemo

Welcome to Nemo version 0.49.1

Nemo comes with absolutely no warranty whatsoever

julia> R = universal_polynomial_ring(QQ)
Universal Polynomial Ring over Rational field

julia> xs200 = gen.(Ref(R), [Symbol("x$i") for i in 1:200])
200-element Vector{AbstractAlgebra.Generic.UnivPoly{QQFieldElem}}:
 x1
 x2
 x3
 x4
 x5
 x6
 x7
 x8
 x9
 x10
 x11
 x12
 x13
 
 x188
 x189
 x190
 x191
 x192
 x193
 x194
 x195
 x196
 x197
 x198
 x199
 x200

julia> y = gen(R, :y)
y

julia> using BenchmarkTools

julia> @benchmark xs200[end] == y
BenchmarkTools.Trial: 10000 samples with 196 evaluations per sample.
 Range (min  max):  469.362 ns   40.940 μs  ┊ GC (min  max):  0.00%  96.81%
 Time  (median):     548.643 ns               ┊ GC (median):     0.00%
 Time  (mean ± σ):   703.006 ns ± 918.173 ns  ┊ GC (mean ± σ):  14.93% ± 16.03%

   ▆█▆▃▂▃▁                                   ▁        ▁▁        ▁
  ▇████████▆▇█▇▇▅▆▃▃▁▄▁▁▃▁▁▁▁▁▃▁▃▁▁▁▃▁▁▁▁▁▄▆███▇▆▇▆▁▃███▇▇██▇▅▆ █
  469 ns        Histogram: log(frequency) by time       2.55 μs <

 Memory estimate: 4.84 KiB, allocs estimate: 5.

julia> 

Sorry for not realising this earlier :(

Originally posted by @karlwessel in #2028 (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