From 2b3f225f20c1594383ff6d1b59fd9d21dffa8f79 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 28 Jun 2021 18:30:55 -0400 Subject: [PATCH] make `Task` smaller by rearranging fields (#41351) This makes jl_task_t 8 bytes smaller, moving it into the next-smallest pool, which drops the effective size from 400 to 368 bytes. --- src/jltypes.c | 16 ++++++++-------- src/julia.h | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/jltypes.c b/src/jltypes.c index f6200daf650231..f9f60f1227b9a7 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2539,13 +2539,13 @@ void jl_init_types(void) JL_GC_DISABLED "result", "logstate", "code", - "_state", - "sticky", - "_isexception", "rngState0", "rngState1", "rngState2", - "rngState3"), + "rngState3", + "_state", + "sticky", + "_isexception"), jl_svec(14, jl_any_type, jl_any_type, @@ -2554,13 +2554,13 @@ void jl_init_types(void) JL_GC_DISABLED jl_any_type, jl_any_type, jl_any_type, - jl_uint8_type, - jl_bool_type, - jl_bool_type, jl_uint64_type, jl_uint64_type, jl_uint64_type, - jl_uint64_type), + jl_uint64_type, + jl_uint8_type, + jl_bool_type, + jl_bool_type), jl_emptysvec, 0, 1, 6); jl_value_t *listt = jl_new_struct(jl_uniontype_type, jl_task_type, jl_nothing_type); diff --git a/src/julia.h b/src/julia.h index faa738913af180..3455817cf1a923 100644 --- a/src/julia.h +++ b/src/julia.h @@ -1829,24 +1829,24 @@ typedef struct _jl_task_t { jl_value_t *result; jl_value_t *logstate; jl_function_t *start; - uint8_t _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - uint8_t _isexception; // set if `result` is an exception to throw or that we exited with uint64_t rngState0; // really rngState[4], but more convenient to split uint64_t rngState1; uint64_t rngState2; uint64_t rngState3; + uint8_t _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + uint8_t _isexception; // set if `result` is an exception to throw or that we exited with // hidden state: + // id of owning thread - does not need to be defined until the task runs + int16_t tid; + // multiqueue priority + int16_t prio; // saved gc stack top for context switches jl_gcframe_t *gcstack; size_t world_age; // quick lookup for current ptls jl_tls_states_t *ptls; // == jl_all_tls_states[tid] - // id of owning thread - does not need to be defined until the task runs - int16_t tid; - // multiqueue priority - int16_t prio; // saved exception stack jl_excstack_t *excstack; // current exception handler