[前][次][番号順一覧][スレッド一覧]

ruby-changes:52168

From: normal <ko1@a...>
Date: Wed, 15 Aug 2018 14:54:47 +0900 (JST)
Subject: [ruby-changes:52168] normal:r64376 (trunk): vm_core.h (rb_thread_t): pack small fields together

normal	2018-08-15 14:54:41 +0900 (Wed, 15 Aug 2018)

  New Revision: 64376

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64376

  Log:
    vm_core.h (rb_thread_t): pack small fields together
    
    On a 64-bit system, this reduces rb_thread_t from 536 to 520 bytes.
    Depending on the allocation, this can reduce cacheline access
    for checking the abort_on_exception, report_on_exception and
    pending_interrupt_queue_checked flags.

  Modified files:
    trunk/thread.c
    trunk/vm_core.h
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 64375)
+++ vm_core.h	(revision 64376)
@@ -879,9 +879,14 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L879
 #ifdef NON_SCALAR_THREAD_ID
     rb_thread_id_string_t thread_id_string;
 #endif
-    enum rb_thread_status status;
-    int to_kill;
-    int priority;
+    BITFIELD(enum rb_thread_status) status : 2;
+    /* bit flags */
+    unsigned int to_kill : 1;
+    unsigned int abort_on_exception: 1;
+    unsigned int report_on_exception: 1;
+    unsigned int pending_interrupt_queue_checked: 1;
+    int8_t priority; /* -3 .. 3 (RUBY_THREAD_PRIORITY_{MIN,MAX}) */
+    uint32_t running_time_us; /* 12500..800000 */
 
     native_thread_data_t native_thread_data;
     void *blocking_region_buffer;
@@ -919,12 +924,7 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L924
 
     /* misc */
     VALUE name;
-    uint32_t running_time_us; /* 12500..800000 */
 
-    /* bit flags */
-    unsigned int abort_on_exception: 1;
-    unsigned int report_on_exception: 1;
-    unsigned int pending_interrupt_queue_checked: 1;
 } rb_thread_t;
 
 typedef enum {
Index: thread.c
===================================================================
--- thread.c	(revision 64375)
+++ thread.c	(revision 64376)
@@ -3608,7 +3608,7 @@ rb_thread_priority_set(VALUE thread, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L3608
     else if (priority < RUBY_THREAD_PRIORITY_MIN) {
 	priority = RUBY_THREAD_PRIORITY_MIN;
     }
-    target_th->priority = priority;
+    target_th->priority = (int8_t)priority;
 #endif
     return INT2NUM(target_th->priority);
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]