Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
deddffab
Commit
deddffab
authored
Apr 03, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let emacs reformat the long comment lbock.
(Thanks for the comments, Toby!)
parent
a0a80adf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
129 deletions
+123
-129
src/Persistence/cPickleCache.c
src/Persistence/cPickleCache.c
+41
-43
src/ZODB/cPickleCache.c
src/ZODB/cPickleCache.c
+41
-43
src/persistent/cPickleCache.c
src/persistent/cPickleCache.c
+41
-43
No files found.
src/Persistence/cPickleCache.c
View file @
deddffab
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
Persistent Classes are part of ZClasses. They are stored in the
Persistent Classes are part of ZClasses. They are stored in the
self->data dictionary, and are never garbage collected.
self->data dictionary, and are never garbage collected.
The klass_items() method returns a sequence of (oid,object) tuples
The klass_items() method returns a sequence of (oid,object) tuples
for
for every Persistent Class, which should make it possible to
every Persistent Class, which should make it possible to implement
implement
garbage collection in Python if necessary.
garbage collection in Python if necessary.
Regime 2: Ghost Objects
Regime 2: Ghost Objects
There is no benefit to keeping a ghost object which has no
There is no benefit to keeping a ghost object which has no
external
external references, therefore a weak reference scheme is
references, therefore a weak reference scheme is used to ensure that
used to ensure that ghost objects are removed from memory
ghost objects are removed from memory as soon as possible, when the
as soon as possible, when the
last external reference is lost.
last external reference is lost.
Ghost objects are stored in the self->data dictionary. Normally
Ghost objects are stored in the self->data dictionary. Normally
a
a dictionary keeps a strong reference on its values, however
dictionary keeps a strong reference on its values, however this
this
reference count is 'stolen'.
reference count is 'stolen'.
This weak reference scheme leaves a dangling reference, in the
This weak reference scheme leaves a dangling reference, in the
dictionary, when the last external reference is lost. To clean up
dictionary, when the last external reference is lost. To clean up
this
this dangling reference the persistent object dealloc function
dangling reference the persistent object dealloc function calls
calls self->cache->_oid_unreferenced(self->oid). The cache looks
self->cache->_oid_unreferenced(self->oid). The cache looks up the oid
up the oid in the dictionary, ensures it points to an object whos
e
in the dictionary, ensures it points to an object whose referenc
e
reference count is zero, then removes it from the dictionary. Before
count is zero, then removes it from the dictionary. Before removing
removing the object from the dictionary it must temporarily resurrect
the object from the dictionary it must temporarily resurrect the
the
object in much the same way that class instances are resurrected
object in much the same way that class instances are resurrected
before their __del__ is called.
before their __del__ is called.
Since ghost objects are stored under a different regime to
Since ghost objects are stored under a different regime to
non-ghost
non-ghost objects, an extra ghostify function in cPersistenceAPI
objects, an extra ghostify function in cPersistenceAPI replaces
replaces self->state=GHOST_STATE assignments that were common in
self->state=GHOST_STATE assignments that were common in other
other
persistent classes (such as BTrees).
persistent classes (such as BTrees).
Regime 3: Non-Ghost Objects
Regime 3: Non-Ghost Objects
Non-ghost objects are stored in two data structures. Firstly, in
Non-ghost objects are stored in two data structures. Firstly, in
the
the
dictionary along with everything else, with a *strong* reference.
dictionary along with everything else, with a *strong* reference.
Secondly, they are stored in a doubly-linked-list which encodes
Secondly, they are stored in a doubly-linked-list which encodes
the
the
order in which these objects have been most recently used.
order in which these objects have been most recently used.
The doubly-link-list nodes contain next and previous pointers
The doubly-link-list nodes contain next and previous pointers
linking
linking
together the cache and all non-ghost persistent objects.
together the cache and all non-ghost persistent objects.
The node embedded in the cache is the home position. On every
The node embedded in the cache is the home position. On every
attribute access a non-ghost object will relink itself just
attribute access a non-ghost object will relink itself just behind the
behind the home position in the ring. Objects accessed least
home position in the ring. Objects accessed least recently will
recently will eventually find themselves positioned after
eventually find themselves positioned after the home position.
the home position.
Occasionally other nodes are temporarily inserted in the ring as
Occasionally other nodes are temporarily inserted in the ring
position markers. The cache contains a ring_lock flag which must be
as position markers. The cache contains a ring_lock flag which
set and unset before and after doing so. Only if the flag is unset can
must be set and unset before and after doing so. Only if the flag
the cache assume that all nodes are either his own home node, or nodes
is unset can the cache assume that all nodes are either his own
from persistent objects. This assumption is useful during the garbage
home node, or nodes from persistent objects. This assumption is
collection process.
useful during the garbage collection process.
The number of non-ghost objects is counted in self->non_ghost_count.
The number of non-ghost objects is counted in self->non_ghost_count.
The garbage collection process consists of traversing the ring, and
The garbage collection process consists of traversing the ring, and
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
self->non_ghost_count is down to the target size, or until it
self->non_ghost_count is down to the target size, or until it
reaches the home position again.
reaches the home position again.
Note that objects in the sticky or changed states are still kept
Note that objects in the sticky or changed states are still kept in
in the ring, however they can not be deactivated. The garbage
the ring, however they can not be deactivated. The garbage collection
collection process must skip such objects, rather than deactivating
process must skip such objects, rather than deactivating them.
them.
*/
*/
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.5
2 2002/04/03 17:20:33 htrd
Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.5
3 2002/04/03 17:53:27 jeremy
Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
...
src/ZODB/cPickleCache.c
View file @
deddffab
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
Persistent Classes are part of ZClasses. They are stored in the
Persistent Classes are part of ZClasses. They are stored in the
self->data dictionary, and are never garbage collected.
self->data dictionary, and are never garbage collected.
The klass_items() method returns a sequence of (oid,object) tuples
The klass_items() method returns a sequence of (oid,object) tuples
for
for every Persistent Class, which should make it possible to
every Persistent Class, which should make it possible to implement
implement
garbage collection in Python if necessary.
garbage collection in Python if necessary.
Regime 2: Ghost Objects
Regime 2: Ghost Objects
There is no benefit to keeping a ghost object which has no
There is no benefit to keeping a ghost object which has no
external
external references, therefore a weak reference scheme is
references, therefore a weak reference scheme is used to ensure that
used to ensure that ghost objects are removed from memory
ghost objects are removed from memory as soon as possible, when the
as soon as possible, when the
last external reference is lost.
last external reference is lost.
Ghost objects are stored in the self->data dictionary. Normally
Ghost objects are stored in the self->data dictionary. Normally
a
a dictionary keeps a strong reference on its values, however
dictionary keeps a strong reference on its values, however this
this
reference count is 'stolen'.
reference count is 'stolen'.
This weak reference scheme leaves a dangling reference, in the
This weak reference scheme leaves a dangling reference, in the
dictionary, when the last external reference is lost. To clean up
dictionary, when the last external reference is lost. To clean up
this
this dangling reference the persistent object dealloc function
dangling reference the persistent object dealloc function calls
calls self->cache->_oid_unreferenced(self->oid). The cache looks
self->cache->_oid_unreferenced(self->oid). The cache looks up the oid
up the oid in the dictionary, ensures it points to an object whos
e
in the dictionary, ensures it points to an object whose referenc
e
reference count is zero, then removes it from the dictionary. Before
count is zero, then removes it from the dictionary. Before removing
removing the object from the dictionary it must temporarily resurrect
the object from the dictionary it must temporarily resurrect the
the
object in much the same way that class instances are resurrected
object in much the same way that class instances are resurrected
before their __del__ is called.
before their __del__ is called.
Since ghost objects are stored under a different regime to
Since ghost objects are stored under a different regime to
non-ghost
non-ghost objects, an extra ghostify function in cPersistenceAPI
objects, an extra ghostify function in cPersistenceAPI replaces
replaces self->state=GHOST_STATE assignments that were common in
self->state=GHOST_STATE assignments that were common in other
other
persistent classes (such as BTrees).
persistent classes (such as BTrees).
Regime 3: Non-Ghost Objects
Regime 3: Non-Ghost Objects
Non-ghost objects are stored in two data structures. Firstly, in
Non-ghost objects are stored in two data structures. Firstly, in
the
the
dictionary along with everything else, with a *strong* reference.
dictionary along with everything else, with a *strong* reference.
Secondly, they are stored in a doubly-linked-list which encodes
Secondly, they are stored in a doubly-linked-list which encodes
the
the
order in which these objects have been most recently used.
order in which these objects have been most recently used.
The doubly-link-list nodes contain next and previous pointers
The doubly-link-list nodes contain next and previous pointers
linking
linking
together the cache and all non-ghost persistent objects.
together the cache and all non-ghost persistent objects.
The node embedded in the cache is the home position. On every
The node embedded in the cache is the home position. On every
attribute access a non-ghost object will relink itself just
attribute access a non-ghost object will relink itself just behind the
behind the home position in the ring. Objects accessed least
home position in the ring. Objects accessed least recently will
recently will eventually find themselves positioned after
eventually find themselves positioned after the home position.
the home position.
Occasionally other nodes are temporarily inserted in the ring as
Occasionally other nodes are temporarily inserted in the ring
position markers. The cache contains a ring_lock flag which must be
as position markers. The cache contains a ring_lock flag which
set and unset before and after doing so. Only if the flag is unset can
must be set and unset before and after doing so. Only if the flag
the cache assume that all nodes are either his own home node, or nodes
is unset can the cache assume that all nodes are either his own
from persistent objects. This assumption is useful during the garbage
home node, or nodes from persistent objects. This assumption is
collection process.
useful during the garbage collection process.
The number of non-ghost objects is counted in self->non_ghost_count.
The number of non-ghost objects is counted in self->non_ghost_count.
The garbage collection process consists of traversing the ring, and
The garbage collection process consists of traversing the ring, and
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
self->non_ghost_count is down to the target size, or until it
self->non_ghost_count is down to the target size, or until it
reaches the home position again.
reaches the home position again.
Note that objects in the sticky or changed states are still kept
Note that objects in the sticky or changed states are still kept in
in the ring, however they can not be deactivated. The garbage
the ring, however they can not be deactivated. The garbage collection
collection process must skip such objects, rather than deactivating
process must skip such objects, rather than deactivating them.
them.
*/
*/
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.5
2 2002/04/03 17:20:33 htrd
Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.5
3 2002/04/03 17:53:27 jeremy
Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
...
src/persistent/cPickleCache.c
View file @
deddffab
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
...
@@ -21,58 +21,57 @@ Regime 1: Persistent Classes
Persistent Classes are part of ZClasses. They are stored in the
Persistent Classes are part of ZClasses. They are stored in the
self->data dictionary, and are never garbage collected.
self->data dictionary, and are never garbage collected.
The klass_items() method returns a sequence of (oid,object) tuples
The klass_items() method returns a sequence of (oid,object) tuples
for
for every Persistent Class, which should make it possible to
every Persistent Class, which should make it possible to implement
implement
garbage collection in Python if necessary.
garbage collection in Python if necessary.
Regime 2: Ghost Objects
Regime 2: Ghost Objects
There is no benefit to keeping a ghost object which has no
There is no benefit to keeping a ghost object which has no
external
external references, therefore a weak reference scheme is
references, therefore a weak reference scheme is used to ensure that
used to ensure that ghost objects are removed from memory
ghost objects are removed from memory as soon as possible, when the
as soon as possible, when the
last external reference is lost.
last external reference is lost.
Ghost objects are stored in the self->data dictionary. Normally
Ghost objects are stored in the self->data dictionary. Normally
a
a dictionary keeps a strong reference on its values, however
dictionary keeps a strong reference on its values, however this
this
reference count is 'stolen'.
reference count is 'stolen'.
This weak reference scheme leaves a dangling reference, in the
This weak reference scheme leaves a dangling reference, in the
dictionary, when the last external reference is lost. To clean up
dictionary, when the last external reference is lost. To clean up
this
this dangling reference the persistent object dealloc function
dangling reference the persistent object dealloc function calls
calls self->cache->_oid_unreferenced(self->oid). The cache looks
self->cache->_oid_unreferenced(self->oid). The cache looks up the oid
up the oid in the dictionary, ensures it points to an object whos
e
in the dictionary, ensures it points to an object whose referenc
e
reference count is zero, then removes it from the dictionary. Before
count is zero, then removes it from the dictionary. Before removing
removing the object from the dictionary it must temporarily resurrect
the object from the dictionary it must temporarily resurrect the
the
object in much the same way that class instances are resurrected
object in much the same way that class instances are resurrected
before their __del__ is called.
before their __del__ is called.
Since ghost objects are stored under a different regime to
Since ghost objects are stored under a different regime to
non-ghost
non-ghost objects, an extra ghostify function in cPersistenceAPI
objects, an extra ghostify function in cPersistenceAPI replaces
replaces self->state=GHOST_STATE assignments that were common in
self->state=GHOST_STATE assignments that were common in other
other
persistent classes (such as BTrees).
persistent classes (such as BTrees).
Regime 3: Non-Ghost Objects
Regime 3: Non-Ghost Objects
Non-ghost objects are stored in two data structures. Firstly, in
Non-ghost objects are stored in two data structures. Firstly, in
the
the
dictionary along with everything else, with a *strong* reference.
dictionary along with everything else, with a *strong* reference.
Secondly, they are stored in a doubly-linked-list which encodes
Secondly, they are stored in a doubly-linked-list which encodes
the
the
order in which these objects have been most recently used.
order in which these objects have been most recently used.
The doubly-link-list nodes contain next and previous pointers
The doubly-link-list nodes contain next and previous pointers
linking
linking
together the cache and all non-ghost persistent objects.
together the cache and all non-ghost persistent objects.
The node embedded in the cache is the home position. On every
The node embedded in the cache is the home position. On every
attribute access a non-ghost object will relink itself just
attribute access a non-ghost object will relink itself just behind the
behind the home position in the ring. Objects accessed least
home position in the ring. Objects accessed least recently will
recently will eventually find themselves positioned after
eventually find themselves positioned after the home position.
the home position.
Occasionally other nodes are temporarily inserted in the ring as
Occasionally other nodes are temporarily inserted in the ring
position markers. The cache contains a ring_lock flag which must be
as position markers. The cache contains a ring_lock flag which
set and unset before and after doing so. Only if the flag is unset can
must be set and unset before and after doing so. Only if the flag
the cache assume that all nodes are either his own home node, or nodes
is unset can the cache assume that all nodes are either his own
from persistent objects. This assumption is useful during the garbage
home node, or nodes from persistent objects. This assumption is
collection process.
useful during the garbage collection process.
The number of non-ghost objects is counted in self->non_ghost_count.
The number of non-ghost objects is counted in self->non_ghost_count.
The garbage collection process consists of traversing the ring, and
The garbage collection process consists of traversing the ring, and
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
...
@@ -80,17 +79,16 @@ deactivating (that is, turning into a ghost) every object until
self->non_ghost_count is down to the target size, or until it
self->non_ghost_count is down to the target size, or until it
reaches the home position again.
reaches the home position again.
Note that objects in the sticky or changed states are still kept
Note that objects in the sticky or changed states are still kept in
in the ring, however they can not be deactivated. The garbage
the ring, however they can not be deactivated. The garbage collection
collection process must skip such objects, rather than deactivating
process must skip such objects, rather than deactivating them.
them.
*/
*/
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.5
2 2002/04/03 17:20:33 htrd
Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.5
3 2002/04/03 17:53:27 jeremy
Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment