
"Chris M. Thomasson" <cristom@charter.net> wrote in message news:hj84tr$7r8$1@ger.gmane.org...
"Helge Bahmann" <hcb@chaoticmind.net> wrote in message news:alpine.DEB.1.10.1001191553030.25332@m65s28.vlinux.de... [...] Now, I can think of a possible optimization/enhancement to the proxy algorithm itself. Take note that an odd reference count denotes that a collection cycle is in progress. Therefore, if a reader thread can simply test if the reference count of it's acquired collector object is even, then it simple does not actually "need" to release a reference to it. If it's odd, then a release is necessary in order to move along the current collection process. This would allow the reader threads acquire/release pattern to be amortized across the actual garbage deferment threshold. I think I am going to alter the algorithm in order to support the following usage pattern: __________________________________________________________________ #define DEFER_THRESHOLD 256
typedef proxy<DEFER_THRESHOLD> proxy_type;
static proxy_type g_proxy;
void reader_thread() { proxy_type::collector* c = &g_proxy.acquire();
for (;;) { query_type* q = try_to_get_a_query_request();
if (! q) { g_proxy.release(*c);
q = wait_for_a_query_request();
c = &g_proxy.acquire(); }
execute_query(q);
if (c->is_collecting()) { g_proxy.release(*c);
c = &g_proxy.acquire(); } }
g_proxy.release(*c); } __________________________________________________________________
This would allow reader threads to curn along during periods of load with fairly low overhead. I say this because the only time the readers would have to release their collector object and re-acquire it is when they must explicitly wait for query requests, or when the garbage threshold was reached and a collection cycle was initiated by a writer thread. There are some fairly promising enhancements I think I can make to the collector, and that is one of them.
Humm...
Refer to the following message over in `comp.programming.threads' for a model of the pattern above in Relacy 2.2: http://groups.google.com/group/comp.programming.threads/msg/f03f8435a1792061 Enjoy! ;^)