From: Nicholas Clark Date: Sat, 17 Sep 2005 17:09:25 +0000 (+0000) Subject: Add emulate the per-thread memory pool on Unix to the TODO X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c99e3826c46ffcfffa9fb9cdc6d049c77e4d8112;p=p5sagit%2Fp5-mst-13.2.git Add emulate the per-thread memory pool on Unix to the TODO p4raw-id: //depot/perl@25439 --- diff --git a/pod/perltodo.pod b/pod/perltodo.pod index e315cd3..0caa728 100644 --- a/pod/perltodo.pod +++ b/pod/perltodo.pod @@ -273,6 +273,37 @@ anyone feeling like exercising their skill with coverage and profiling tools might want to determine what ops I are the most commonly used. And in turn suggest evictions and promotions to achieve a better F. +=head2 emulate the per-thread memory pool on Unix + +For Windows, ithreads allocates memory for each thread from a separate pool, +which it discards at thread exit. It also checks that memory is free()d to +the correct pool. Neither check is done on Unix, so code developed there won't +be subject to such strictures, so can harbour bugs that only show up when the +code reaches Windows. + +It would be good to be able to optionally emulate the Window pool system on +Unix, to let developers who only have access to Unix, or want to use +Unix-specific debugging tools, check for these problems. To do this would +involve figuring out how the C macros wrap C access, and +providing a layer that records/checks the identity of the thread making the +call, and recording all the memory allocated by each thread via this API so +that it can be summarily free()d at thread exit. One implementation idea +would be to increase the size of allocation, and store the C pointer +(to identify the thread) at the start, along with pointers to make a linked +list of blocks for this thread. To avoid alignment problems it would be +necessary to do something like + + union memory_header_padded { + struct memory_header { + void *thread_id; /* For my_perl */ + void *next; /* Pointer to next block for this thread */ + } data; + long double padding; /* whatever type has maximal alignment constraint */ + }; + + +although C might not be the only type to add to the padding +union.