Attached is the second set of patches for the tracked resource memory
management system.

Features:
Separate memory pools for buffers, normal strings, constant strings; the
latter is never compacted
Each pool has its own alignment; these are currently set to 16, 4 and 2
respectively; suggestions welcome
The current default allocations for these pools are: 16K, 32K and 8K
respectively.
Separate header pools for normal vs constant strings; the latter is never
subjected to dead object detection
String and Buffer processing combined as much as possible, since a string is
really just a specialised buffer
Most of the compile-time constants have been moved to variables; this will
allow for dynamic changes to parameters

API changes:
I decided not to add new functions for allocating constant string headers
and buffers. Instead, the constant flag must be set in the flags passed to
string_make; these flags are now passed to new_string_header, and it will
use the constant pool if requested.
Currently, this only affects packfile.c, the patch for which is included
herein. Note that changing the value of the constant flag during the life of
a string could be detrimental to something.

Other changes:
A new opcode 'stringinfo' has been added to core.ops to allow access to the
innards of a STRING, the list of arguments can be found in string.h. This
currently serves very little purpose, but it will be useful for writing
tests for COW, when this is added (shortly?)
The code for 'open' in io.ops has been amended to use string_to_cstring
instead of its own null-termination code; this code has mortality issues if
termination of the mode string triggers GC; I have not bothered to handle
that, as the correct solution is to pass Parrot strings directly to
PIO_open.

Still to do:
The current handling of the free pool buffers in compact_buffer_pool is
messy, and introduces another place that code needs to be added if a new
resource type is added. I am currently thinking along the lines of some sort
of 'system buffer' list, containing pointers to any buffer headers that are
not in the normal arenas, but still need to be included in the collection
process.
COW will be added within a day or two; initially, just for full strings, as
this doesn't need changes to anything outside string/resources
String mortality still needs further work (e.g. the temporary transcoded
strings created in string_concat, etc)
Statistics collection may be moved to the pool level rather than the
interpreter level, for possible use in dynamic tuning
Documentation!

Performance:
This version is slightly faster in some cases; however, this is due to the
increased memory allocation of the multiple pools, rather than any inherent
improvements.

--
Peter Gibbs
EmKel Systems


Attachment: phase2.patch
Description: Binary data

Reply via email to