Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance of casting ZZ[x] to Qp[x] #15426

Closed
sagetrac-afiori mannequin opened this issue Nov 16, 2013 · 19 comments
Closed

Performance of casting ZZ[x] to Qp[x] #15426

sagetrac-afiori mannequin opened this issue Nov 16, 2013 · 19 comments

Comments

@sagetrac-afiori
Copy link
Mannequin

sagetrac-afiori mannequin commented Nov 16, 2013

One probably expects that casting ZZ[x] to Qp[x] is at least as fast as casting QQ[x] to Q[x].
This appeared not to be the case:

sage: prim=primes_first_n(1000)
sage: ZZX=ZZ['x']
sage: QQX=QQ['x']
sage: polysZZ = [ ZZX(prim[i:i+30]) for i in range(1,900)]
sage: polysQQ = [ QQX(prim[i:i+30]) for i in range(1,900)]
sage: QP=Qp(3,30);
sage: QPX=QP['x']

sage: def test1(PR,l):
    return [PR(P) for P in l];
sage: %timeit test1(QPX,polysZZ)
1 loops, best of 3: 395 ms per loop
sage: %timeit test1(QPX,polysQQ)
1 loops, best of 3: 244 ms per loop

This appears to have been caused by unneccisary repeat virtual function calls in polynomial_padic_capped_relative_dense::_comp_valaddeds. The number of excess calls was proportional to the degree of the polynomial, hence this likely does not cause noticeable performance issue for very low degree polynomials.

The attached patch should correct this, I have new timings

sage: %timeit test1(QPX,polysZZ)
1 loops, best of 3: 171 ms per loop
sage: %timeit test1(QPX,polysQQ)
1 loops, best of 3: 256 ms per loop

CC: @roed314 @xcaruso

Component: performance

Keywords: performance padic polynomial casting

Author: Andrew Fiori

Branch/Commit: a297e3c

Reviewer: Xavier Caruso

Issue created by migration from https://trac.sagemath.org/ticket/15426

@sagetrac-afiori sagetrac-afiori mannequin added this to the sage-6.1 milestone Nov 16, 2013
@sagetrac-afiori
Copy link
Mannequin Author

sagetrac-afiori mannequin commented Nov 16, 2013

Eliminate unnecessary function calls

@sagetrac-vbraun-spam
Copy link
Mannequin

sagetrac-vbraun-spam mannequin commented Jan 30, 2014

comment:1

Attachment: PadicPolyCastingInt.patch.gz

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@fchapoton
Copy link
Contributor

Commit: 76581c9

@fchapoton
Copy link
Contributor

Branch: u/chapoton/15426

@fchapoton
Copy link
Contributor

comment:4

I have made the suggested change. It does not seem to have nay impact on the speed. Maybe worth doing nevertheless. Also some other small changes, that should be good for speed.


New commits:

696b23btrac 5583 adding a doctest
76581c9trac 15426 some details in padic polynomials

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 1, 2019

Changed commit from 76581c9 to d6b6ef1

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 1, 2019

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

d6b6ef1trac 15426 details in padic polynomials

@embray
Copy link
Contributor

embray commented Jul 3, 2019

comment:6

Moving tickets from the Sage 8.8 milestone that have been actively worked on in the last six months to the next release milestone (optimistically).

@embray embray modified the milestones: sage-8.8, sage-8.9 Jul 3, 2019
@fchapoton fchapoton modified the milestones: sage-8.9, sage-9.0 Dec 5, 2019
@embray
Copy link
Contributor

embray commented Jan 6, 2020

comment:8

Ticket retargeted after milestone closed

@embray embray modified the milestones: sage-9.0, sage-9.1 Jan 6, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Apr 14, 2020

comment:9

Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.1, sage-9.2 Apr 14, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Feb 13, 2021

comment:11

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Jul 19, 2021

comment:12

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@fchapoton
Copy link
Contributor

New commits:

a297e3csome details inside one p-adic file

@fchapoton
Copy link
Contributor

Changed commit from d6b6ef1 to a297e3c

@fchapoton
Copy link
Contributor

Changed branch from u/chapoton/15426 to public/ticket/15426

@fchapoton
Copy link
Contributor

comment:16

bot is morally green, so please review !

@xcaruso
Copy link
Contributor

xcaruso commented Jun 2, 2022

comment:17

It's not completely clear to me what really changed but it looks okay.

@fchapoton
Copy link
Contributor

Reviewer: Xavier Caruso

@vbraun
Copy link
Member

vbraun commented Jun 12, 2022

Changed branch from public/ticket/15426 to a297e3c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants