[#69084] [Ruby trunk - Feature #11124] [Open] [PATCH] lib/*: use monotonic clock for timeouts — normalperson@...
Issue #11124 has been reported by Eric Wong.
5 messages
2015/05/06
[#69138] [Ruby trunk - Feature #11136] [PATCH] webrick: avoid fcntl module — nobu@...
Issue #11136 has been updated by Nobuyoshi Nakada.
3 messages
2015/05/12
[#69160] [Ruby trunk - Feature #11146] [PATCH] variable.c: initialize generic_iv_tbl at start — nobu@...
Issue #11146 has been updated by Nobuyoshi Nakada.
4 messages
2015/05/13
[#69175] Re: [Ruby trunk - Feature #11146] [PATCH] variable.c: initialize generic_iv_tbl at start
— Eric Wong <normalperson@...>
2015/05/13
nobu@ruby-lang.org wrote:
[ruby-core:69080] Re: [Ruby trunk - Feature #11098] [Open] Thread-level allocation counting
From:
Eric Wong <normalperson@...>
Date:
2015-05-06 09:13:15 UTC
List:
ruby-core #69080
I don't mind this patch and even see it as an opportunity to drop
objspace->total_allocated_objects entirely and rely exclusively on
thread-local counters for GC.
I toyed around with a similar idea last year in [ruby-core:61424] for
malloc accounting but haven't gotten much further. I might investigate
this again over the summer.
Anyways some minor nits inline:
> --- a/gc.c
> +++ b/gc.c
> @@ -1741,6 +1741,10 @@ newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3)
> #endif
>
> objspace->total_allocated_objects++;
> +
> + rb_thread_t *th = GET_THREAD();
> + th->allocated_objects++;
That would trip -Werror=declaration-after-statement in GCC. Declare
`th' earlier or avoid the local variable entirely since you're only
reading that once.
GET_THREAD()->allocated_objects++;
> --- a/thread.c
> +++ b/thread.c
> @@ -2568,6 +2568,14 @@ rb_thread_group(VALUE thread)
> return group;
> }
>
> +VALUE
> +rb_thread_allocated_objects(VALUE thread)
> +{
> + rb_thread_t *th;
> + GetThreadPtr(thread, th);
> + return LONG2NUM(th->allocated_objects);
> +}
> --- a/vm_core.h
> +++ b/vm_core.h
> @@ -598,6 +598,7 @@ typedef struct rb_thread_struct {
> int safe_level;
> int raised_flag;
> VALUE last_status; /* $? */
> + long allocated_objects;
Use uint64_t to avoid overflow on 32-bit systems as this counter never
resets. This should never be a signed value.