You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Bruce Mitchener (JIRA)" <ji...@apache.org> on 2010/05/25 14:43:23 UTC

[jira] Created: (AVRO-553) Memory management: Allocator interface supports contexts

Memory management: Allocator interface supports contexts
--------------------------------------------------------

                 Key: AVRO-553
                 URL: https://issues.apache.org/jira/browse/AVRO-553
             Project: Avro
          Issue Type: Improvement
          Components: c
            Reporter: Bruce Mitchener
            Assignee: Bruce Mitchener
             Fix For: 1.4.0


I'm working on a major revision to the new memory management interface to support allocating within contexts. This will let pluggable memory management be far more useful so that we can support things like a linear allocator that is used for each request (and reset afterwards).

This will involve a fair bit of work to fully support it, so I'll attach a series of patches as I work through things.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AVRO-553) Memory management: Allocator interface supports contexts

Posted by "Bruce Mitchener (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Mitchener updated AVRO-553:
---------------------------------

    Attachment: avro_553.diff

Overall idea can start to be seen here:

+#define AVRO_MALLOC_CTX(ctx, size) ctx.malloc(&ctx, size)
+#define AVRO_CALLOC_CTX(ctx, count, size) ctx.calloc(&ctx, count, size)
+#define AVRO_REALLOC_CTX(ctx, ptr, size) ctx.realloc(&ctx, ptr, size)
+#define AVRO_FREE_CTX(ctx, ptr) ctx.free(&ctx, ptr)
+#define AVRO_STRDUP_CTX(ctx, source) avro_strdup(&ctx, source)
+
+#define AVRO_MALLOC(size) AVRO_MALLOC_CTX(g_avro_allocator, size)
+#define AVRO_CALLOC(count, size) AVRO_CALLOC_CTX(g_avro_allocator, count, size)
+#define AVRO_REALLOC(ptr, size) AVRO_REALLOC_CTX(g_avro_allocator, ptr, size)
+#define AVRO_FREE(ptr) AVRO_FREE_CTX(g_avro_allocator, ptr)
+#define AVRO_STRDUP(source) AVRO_STRDUP_CTX(g_avro_allocator, source)

Using AVRO_MALLOC will allocate within the global allocator.  You can also use AVRO_MALLOC_CTX to specify your own context which can be implemented in whatever manner you like.  You can use the new ctx field on avro_allocator_t to store your own allocator's state.

To get this to really work fully, we'll have to make it so that things can track which allocator was used for them so that they can correctly free themselves. We'll end up working through this over the next while ...

I may check this current patch in as an intermediary step, although, I suspect that I'd be better not to and wait until more of the API changes are done.


> Memory management: Allocator interface supports contexts
> --------------------------------------------------------
>
>                 Key: AVRO-553
>                 URL: https://issues.apache.org/jira/browse/AVRO-553
>             Project: Avro
>          Issue Type: Improvement
>          Components: c
>            Reporter: Bruce Mitchener
>            Assignee: Bruce Mitchener
>             Fix For: 1.4.0
>
>         Attachments: avro_553.diff
>
>
> I'm working on a major revision to the new memory management interface to support allocating within contexts. This will let pluggable memory management be far more useful so that we can support things like a linear allocator that is used for each request (and reset afterwards).
> This will involve a fair bit of work to fully support it, so I'll attach a series of patches as I work through things.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.