From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: Re: [PATCH] struct.c: speedup for big structs
Date: Tue, 30 Jun 2015 20:11:02 +0000 [thread overview]
Message-ID: <20150630201102.GA14164@dcvr.yhbt.net> (raw)
In-Reply-To: <1435011362-18488-1-git-send-email-e@80x24.org>
Eric Wong <e@80x24.org> wrote:
> use simple custom open-addressing hash for big structs.
>
> Thanks to Sokolov Yura aka funny_falcon <funny.falcon@gmail.com>
> in https://bugs.ruby-lang.org/issues/10585
Will squash the following when I commit.
Freezing __members__ is necessary, but
RB_GC_GUARD isn't needed since __members__ already becomes an ivar.
diff --git a/struct.c b/struct.c
index fbde80d..eda5673 100644
--- a/struct.c
+++ b/struct.c
@@ -84,12 +84,13 @@ struct_member_pos_probe(long prev, long mask)
return (prev * 5 + 2) & mask;
}
-static void
+static VALUE
struct_set_members(VALUE klass, VALUE members)
{
VALUE back;
members = rb_ary_dup(members);
+ rb_obj_freeze(members);
if (RARRAY_LEN(members) <= AREF_HASH_THRESHOLD) {
back = members;
@@ -121,7 +122,8 @@ struct_set_members(VALUE klass, VALUE members)
rb_obj_freeze(back);
rb_ivar_set(klass, id_members, members);
rb_ivar_set(klass, id_back_members, back);
- RB_GC_GUARD(members);
+
+ return members;
}
static inline int
@@ -305,8 +307,7 @@ setup_struct(VALUE nstr, VALUE members)
const VALUE *ptr_members;
long i, len;
- OBJ_FREEZE(members);
- struct_set_members(nstr, members);
+ members = struct_set_members(nstr, members);
rb_define_alloc_func(nstr, struct_alloc);
rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
next prev parent reply other threads:[~2015-06-30 20:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 22:16 [PATCH] struct.c: speedup for big structs Eric Wong
2015-06-30 20:11 ` Eric Wong [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-06-22 22:00 Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150630201102.GA14164@dcvr.yhbt.net \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).