Feature #10187
closedminor iseq memory reductions
Description
Pretty trivial and low impact, but I figure we might as well reduce
memory footprint a few kilobytes where we can and let the reductions
accumulate. Feature #10185 has much bigger impact.
- [PATCH 1/2] iseq_inline_storage_entry: 24=>16 bytes on x86-64
We may tag the running_thread pointer to avoid making the "once" struct
bigger than "struct iseq_inline_cache_entry".
This only saves a small amount with "valgrind ruby -e exit"
before:
total heap usage: 48,122 allocs, 19,248 frees, 8,110,149 bytes allocated
after:
total heap usage: 48,122 allocs, 19,253 frees, 8,099,197 bytes allocated
- [PATCH 2/2] rb_call_info_t: 104=>96 bytes on x86-64
This keeps ci->flag and ci->aux.index consistent across 32-bit
and 64-bit platforms.
ci->flag: VM_CALL_* flags only use 9 bits, currently
ci->aux.index: 2 billion ivars per class should be enough for anybody
This saves around 50K allocations on "valgrind ruby -e exit"
before:
total heap usage: 48,122 allocs, 19,253 frees, 8,099,197 bytes allocated
after:
total heap usage: 48,069 allocs, 19,214 frees, 8,047,266 bytes allocated
Files
Updated by normalperson (Eric Wong) almost 11 years ago
- File call_info-96.patch call_info-96.patch added
Missed patch 2/2
Updated by normalperson (Eric Wong) over 10 years ago
- File call_info-96-v2.patch call_info-96-v2.patch added
updated 2/2 patch to adjust for r47456 (redundant SYM2ID <=> ID2SYM removal)
Updated by ko1 (Koichi Sasada) over 10 years ago
Subject: [PATCH] iseq_inline_storage_entry: 24=>16 bytes on x86-64
+#define RUNNING_THREAD_ONCE_DONE ((rb_thread_t *)(0x1))
How about to define macro such as
#define ONCE_FINISHED(once) ((once)->running_thread == 0x01)
and use as
if (ONCE_FINIHSED(&is->once)) { ... }
Subject: [PATCHv2] rb_call_info_t: shrink to 96 bytes from 104 bytes on 64-bit
OK.
Updated by ko1 (Koichi Sasada) over 10 years ago
+ if (newsize > INT_MAX) rb_memerror();
memerror?
Updated by normalperson (Eric Wong) over 10 years ago
[email protected] wrote:
Subject: [PATCH] iseq_inline_storage_entry: 24=>16 bytes on x86-64
+#define RUNNING_THREAD_ONCE_DONE ((rb_thread_t *)(0x1))
How about to define macro such as
#define ONCE_FINISHED(once) ((once)->running_thread == 0x01)
and use as
if (ONCE_FINIHSED(&is->once)) { ... }
I would need another macro for setting 0x1:
+ is->once.running_thread = RUNNING_THREAD_ONCE_DONE; /* success */
I prefer to only introduce one new macro.
Updated by normalperson (Eric Wong) over 10 years ago
[email protected] wrote:
if (newsize > INT_MAX) rb_memerror();
memerror?
I took the hint from compile_data_alloc:
if (size >= INT_MAX) rb_memerror();
if (storage->pos + size > storage->size) {
unsigned int alloc_size = storage->size;
while (alloc_size < size) {
if (alloc_size >= INT_MAX / 2) rb_memerror();
alloc_size *= 2;
Nobody hits the limit, so reusing rb_memerror
keeps code size down.
Updated by ko1 (Koichi Sasada) over 10 years ago
Eric Wong wrote:
Nobody hits the limit, so reusing rb_memerror keeps code size down.
how about to use rb_fatal() to declare give up?
Updated by normalperson (Eric Wong) over 10 years ago
[email protected] wrote:
Eric Wong wrote:
Nobody hits the limit, so reusing rb_memerror keeps code size down.
how about to use rb_fatal() to declare give up?
Actually, nobody hits that check anymore, I removed it.
Correct check is in r47512, thanks nobu!
Updated by normalperson (Eric Wong) over 7 years ago
- Status changed from Open to Closed