Author: Armin Rigo <[email protected]>
Branch: c7
Changeset: r594:a0efd230208b
Date: 2014-01-02 11:57 +0100
http://bitbucket.org/pypy/stmgc/changeset/a0efd230208b/
Log: Comments
diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -478,6 +478,18 @@
static void reset_transaction_read_version(void)
{
/* force-reset all read markers to 0 */
+
+ /* XXX measure the time taken by this madvise() and the following
+ zeroing of pages done lazily by the kernel; compare it with using
+ 16-bit read_versions.
+ */
+ /* XXX try to use madvise() on smaller ranges of memory. In my
+ measures, we could gain a factor 2 --- not really more, even if
+ the range of virtual addresses below is very large, as long as it
+ is already mostly non-reserved pages. (The following call keeps
+ them non-reserved; apparently the kernel just skips them very
+ quickly.)
+ */
int res = madvise(real_address(FIRST_READMARKER_PAGE * 4096UL),
(FIRST_OBJECT_PAGE - FIRST_READMARKER_PAGE) * 4096UL,
MADV_DONTNEED);
@@ -601,9 +613,10 @@
uint16_t cur = (uintptr_t)alloc->next;
if (start == cur) {
- /* nothing to do: this assigned page was left empty by the
- previous transaction, and also starts empty in the new
- transaction. 'flag_partial_page' is unchanged. */
+ /* nothing to do: this page (or fraction thereof) was left
+ empty by the previous transaction, and starts empty as
+ well in the new transaction. 'flag_partial_page' is
+ unchanged. */
}
else {
uintptr_t pagenum = ((uintptr_t)(alloc->next - 1)) / 4096UL;
@@ -616,9 +629,9 @@
}
}
else {
- /* we can skip checking page->private_page because the
- whole page can only contain objects made by the just-
- finished transaction. */
+ /* we can skip checking flag_page_private[] in non-debug
+ builds, because the whole page can only contain
+ objects made by the just-finished transaction. */
assert(flag_page_private[pagenum] == SHARED_PAGE);
/* the next transaction will start with this page
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -13,9 +13,28 @@
typedef TLPREFIX struct read_marker_s read_marker_t;
+/* Structure of objects
+ --------------------
+
+ Objects manipulated by the user program, and managed by this library,
+ must start with a "struct object_s" field. Pointers to any user object
+ must use the "TLPREFIX struct foo *" type --- don't forget TLPREFIX.
+ The best is to use typedefs like above.
+
+ The object_s part contains some fields reserved for the STM library,
+ as well as a 32-bit integer field that can be freely used by the user
+ program. However, right now this field must be read-only --- i.e. it
+ must never be modified on any object that may already belong to a
+ past transaction; you can only set it on just-allocated objects. The
+ best is to consider it as a field that is written to only once on
+ newly allocated objects.
+*/
+
struct object_s {
- uint16_t write_version;
+ uint16_t write_version; /* reserved for the STM library */
/*uint8_t stm_flags;*/
+ uint32_t header; /* for the user program -- only write in
+ newly allocated objects */
};
struct read_marker_s {
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit