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

Proper implementation of object pools #17670

Open
jdemeyer opened this issue Jan 25, 2015 · 52 comments
Open

Proper implementation of object pools #17670

jdemeyer opened this issue Jan 25, 2015 · 52 comments

Comments

@jdemeyer
Copy link

integer.pyx and real_double.pyx use hook_tp_functions() to change tp_new and tp_dealloc at run-time. It seems that one cannot avoid such hacks with the current Cython, but at least we could provide a cleaner interface.

Depends on #24111

CC: @roed314 @saraedum @xcaruso

Component: cython

Keywords: padicIMA, padicBordeaux

Author: Jeroen Demeyer

Branch/Commit: u/roed/proper_implementation_of_object_pools @ d7d56b1

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

@jdemeyer jdemeyer added this to the sage-6.5 milestone Jan 25, 2015
@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer changed the title Get rid of hook_tp_functions() hack Proper implementation of object pools Jan 25, 2015
@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer modified the milestones: sage-6.5, sage-8.1 Sep 26, 2017
@jdemeyer
Copy link
Author

@xcaruso
Copy link
Contributor

xcaruso commented Oct 26, 2017

Commit: 0d7616d

@xcaruso
Copy link
Contributor

xcaruso commented Oct 26, 2017

comment:6

I've just had a look at your implementation (sorry for the delay).

I saw that you stored the address of the pool in a dictionary. Did you try to estimate the time penalty of this dictionary lookup? For instance, did you compare timings between (1) your implementation and (2) the current implementation for integers?

By design, your implementation cannot allow what I've called local pools (several different pools are possible for a same type) and global pools (a unique pool is shared all by all elements having a given type). I'm a bit sad about this because I think that having different pools may really make sense (for instance for p-adics when we are dealing with many different primes p and then objects with different sizes).
But OK, I can accept this :-).

Why are you limiting the number of pools to 4? Isn't it too small?


New commits:

0d7616dProper implementation of object pools

@jdemeyer
Copy link
Author

comment:7

Replying to @xcaruso:

Why are you limiting the number of pools to 4? Isn't it too small?

4 per Cython module.

@jdemeyer
Copy link
Author

comment:8

A more general comment about pools is that everybody has a different set of features. For example, the Integer pool that we currently have in Sage is actually more than just a pool. It also constructs new objects quickly from a prototype object.

@jdemeyer
Copy link
Author

Dependencies: #24111

@jdemeyer
Copy link
Author

comment:10

Let me continue with this... I'm adding a dependency on #24111 because that makes it a lot easier to write modules which are partially implemented in C and partially in Cython.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2017

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

234b7c8Upgrade to Cython 0.27.2
64854cbAdd Cython late include patch
997efe8Proper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2017

Changed commit from 0d7616d to 997efe8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2017

Changed commit from 997efe8 to 2f5f463

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2017

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

2f5f463Proper implementation of object pools

@jdemeyer
Copy link
Author

comment:13

Replying to @xcaruso:

I saw that you stored the address of the pool in a dictionary. Did you try to estimate the time penalty of this dictionary lookup?

I am not doing any dictionary lookup (except for putting the pool in the dict). I am storing the pool in the dict for 2 reasons: for debugging purposes and to ensure that some reference is kept to the pool (to prevent it from being deleted). I do not use this dict in the implementation.

By design, your implementation cannot allow what I've called local pools (several different pools are possible for a same type) and global pools (a unique pool is shared all by all elements having a given type). I'm a bit sad about this because I think that having different pools may really make sense

I never understood the need for local pools. I thought that you stored the pool in the parent only for practical purposes.

and then objects with different sizes

What do you mean with "objects with different sizes"?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2017

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

fe75dd5Proper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2017

Changed commit from 2f5f463 to fe75dd5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2017

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

41dd98bProper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2017

Changed commit from fe75dd5 to 41dd98b

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 8, 2017

Changed commit from 41dd98b to a6b71b8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 8, 2017

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

a6b71b8Proper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 10, 2017

Changed commit from a6b71b8 to 570901e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 10, 2017

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

c331d9bGenerate eclib includes in a predictable order
c0b3a81Add Cython late include patch
570901eProper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 16, 2017

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

c91279cProper implementation of object pools

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 16, 2017

Changed commit from 8d2ab64 to c91279c

@jdemeyer
Copy link
Author

comment:22

There is worrying doctest failure on the patchbot that I'll need to check.

@jdemeyer
Copy link
Author

Changed dependencies from #24111 to #24111, #24259

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

@jdemeyer
Copy link
Author

comment:25

I do intend to come back to this ticket, but this really needs a new version of Cython.


Last 10 new commits:

c3c8692Doctest for the class pRational
9780da5More doctests
b9b4a34Small fix in list_of_padics
241bd7aMerge remote-tracking branch 'trac/develop' into t/23505/lattice_precision
2a94835Merge branch 'u/saraedum/lattice_precision' of git://trac.sagemath.org/sage into lattice_precision
23241e2Address some of Julian's comments
2c334e7100% doctest coverage (hopefully)
a67c96citeritems, python 3 compatibility
6593e23Merge branch 'develop' into lattice_precision
e850b42Merge branch 'u/jdemeyer/proper_implementation_of_object_pools' of git://trac.sagemath.org/sage into proper_pool

@jdemeyer
Copy link
Author

Changed dependencies from #24111, #24259 to #24111

@jdemeyer
Copy link
Author

Changed commit from c91279c to e850b42

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

New commits:

c0b3a81Add Cython late include patch
c91279cProper implementation of object pools

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

Changed commit from e850b42 to c91279c

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

@jdemeyer
Copy link
Author

comment:28

???


New commits:

0c8a03bMerge remote-tracking branch 'trac/develop' into t/17670/proper_implementation_of_object_pools

@jdemeyer
Copy link
Author

Changed commit from c91279c to 0c8a03b

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

comment:29

Sorry, I merged by mistake ticket #23505 into this one.
This should be fixed now.

@jdemeyer
Copy link
Author

comment:30

So the branch should be reset to my branch then?

@xcaruso
Copy link
Contributor

xcaruso commented Feb 26, 2018

comment:31

Well, I also resolved a couple of conflicts, so that my branch is supposed to merge properly with develop.

@jdemeyer
Copy link
Author

comment:32

I see. But given that #24111 is not a "real" ticket, it's better to rebase instead of merge.

@jdemeyer
Copy link
Author

comment:33

#24111 just became a real ticket and it needs review :-)

@roed314
Copy link
Contributor

roed314 commented Jul 22, 2018

Changed keywords from none to padicIMA

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

comment:35

Xavier, Julian and I are going to be working on p-adics this coming week in Bordeaux. I'm just tagging this ticket as one we might want to look at.

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

Changed keywords from padicIMA to padicIMA, padicBordeaux

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

comment:36

Jeroen, we're happy to work on this a bit this week (in particular, resolving merge conflicts). Do you have any known issues with what you've written?

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

comment:38

I resolved the merge conflicts, which were in the cython version level and integer.pyx, but now Sage crashes on startup. When I ran make build, it surprisingly only rebuilt 4 Cython files. Given that there are patches to Cython in this ticket, I think I might need to reinstall Cython with sage -f cython, but I think I'm going to work on other tickets for now rather than try to debug this.


New commits:

d7d56b1Merge branch 'u/caruso/proper_implementation_of_object_pools' of git://trac.sagemath.org/sage into t17670_object_pools

@roed314
Copy link
Contributor

roed314 commented Sep 7, 2019

Changed commit from 0c8a03b to d7d56b1

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

4 participants