ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69995] Re: [Ruby trunk - Feature #11339] [Open] [PATCH] io.c: avoid kwarg parsing in C API
Date: Thu, 16 Jul 2015 07:01:42 +0000
Message-ID: <20150716070142.GA11462@dcvr.yhbt.net> (raw)
In-Reply-To: <55A72930.40305@atdot.net>

SASADA Koichi <ko1@atdot.net> wrote:
> On 2015/07/16 4:41, Eric Wong wrote:
> > normalperson@yhbt.net wrote:
> >> Feature #11339: [PATCH] io.c: avoid kwarg parsing in C API
> >> https://bugs.ruby-lang.org/issues/11339
> > 
> >> Note: I plan to followup commits for other *_nonblock methods
> >> Eventually, I even wish to deprecate rb_scan_args :D
> >>
> >> For what it's worth, I'm more excited about this change than usual
> >> and hope to use prelude.rb more.
> > 
> > ko1/nobu/akr/others: any comments on this?
> > 
> > My main concern is increased parse time from prelude during startup;
> > but we may translate prelude to iseq array and use rb_iseq_load, too.
> > The parser seems to be the worst offender for startup performance
> > nowadays.
> 
> We have some ideas to solve this issue. We discussed about solutions.
> 
> Known problems about C-methods parameters:
> (P1) slow to parse kwargs with Hash
> (P2) difficult to write scan_args
> (P3) C-methods can't support Method#parameters

Thank you for response.

> Solutions:
> 
> (1) Introduce wrapping Ruby methods into prelude.rb (your idea)
>   Pros. Easy to introduce.
>         Solves (P1-3).
>   Cons. Increase parse time at Ruby launch.

We cannot avoid parsing Ruby :)  So I want to try to make parsing faster.
Unfortunately, my parser knowledge is not much right now.

> (2) Introduce new API to declare Ruby-like parameters for C-APIs
> 
> like: rb_define_method(klass, "xyzzy", klass_xyzzy, -1)
> 
> (2-1)
> -> rb_defnie_method_??(klass, "xyzzy", klass_xyzzy,
>                        "(m1, m2, o1=nil, o2=nil,
>                         *r, p1, p2, k1: 1, k2: 2)")

OK, I had the same idea like this, too.
But I do not want to introduce a new C API.  IMHO, C API should be
smaller, not bigger.

> (3) Introduce new IDL (Interface Definition Language)

This may be OK... I don't see a big advantage over (1).

> (4) Introduce new IDL like Ricsin
> 
> I made a system calls Ricsin, which enable to embed C code into Ruby code.

I think this is too ugly.  One reason I like Ruby + (limited) C use is
relatively good separation between the different languages.

Working on C-ext is mostly normal C, and not some weird in-between
thing like Perl XS (gross!).  Existing C programmers do not need to
learn a lot of new things to work with current CRuby.

I think it is important that we can use C tools (gdb, ctags, sparse,
etc...) can work without modification.  But I still want to reduce C
and use more Ruby[1].

> I'm okay to introduce (1) because it is easy and practical.

OK, thank you.  I will commit (1) this week and work on more prelude.rb
for other IO/Socket kwargs methods.

> If we can make (2)-(4), then we can replace from (1) to new mechanism.

> BTW, I'm working on making AOT compilation support (it will be continued
> to (3) or (4)). Recent rb_iseq_t changes were for this purpose. So that
> prelude.rb is nice benchmark for me.

I want to speed up Ruby parsing + startup in general, too.

Along the lines of AOT: I also consider having something like ccache
(self-managing size, only in $HOME, hashing-based) using rb_iseq_load.

I don't want to pollute users disk with too many compiled files; and it
should use hashing so we may tweak formats/architectures and not worry
about path conflicts with concurrently-installed Ruby versions.

We already have too many bug reports because C-exts/objs get shared.



[1] Fwiw, I like Rubinius philosophy a lot.  However, the non-Free
    contribution platform and eventual implementation
    (slow startup time, "Ruby environment" vs being "another *nix tool"
     which CRuby/Perl are) put me off.

  reply	other threads:[~2015-07-16  6:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11339.20150707215946@ruby-lang.org>
2015-07-07 21:59 ` [ruby-core:69892] " normalperson
2015-07-15 19:41   ` [ruby-core:69983] " Eric Wong
2015-07-16  3:46     ` [ruby-core:69990] " SASADA Koichi
2015-07-16  7:01       ` Eric Wong [this message]
2015-07-16  9:17         ` [ruby-core:69999] " SASADA Koichi
2015-10-09 23:35           ` [ruby-core:71035] " Eric Wong
2015-11-10 22:27   ` [ruby-core:71435] " Eric Wong
2015-12-02  2:23   ` [ruby-core:71789] " Eric Wong
2015-11-11  5:20 ` [ruby-core:71439] [Ruby trunk - Feature #11339] " matz
2015-11-12  2:03   ` [ruby-core:71459] " Eric Wong
2015-11-12  9:53     ` [ruby-core:71462] " Eric Wong
2015-11-18  2:07     ` [ruby-core:71539] " Eric Wong
2015-11-13  4:18   ` [ruby-core:71473] " Eric Wong
2015-11-13  5:46     ` [ruby-core:71478] " SASADA Koichi
2015-11-13  7:03       ` [ruby-core:71479] " Eric Wong
2015-12-27 22:49 ` [ruby-core:72527] " headius
2015-12-27 23:00 ` [ruby-core:72528] " headius
2015-12-27 23:40   ` [ruby-core:72529] " Eric Wong
2015-12-28  0:13 ` [ruby-core:72530] " headius
2015-12-28  1:12   ` [ruby-core:72532] " Eric Wong
2015-12-28  0:22 ` [ruby-core:72531] " headius
2015-12-28  1:50 ` [ruby-core:72535] " headius

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-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150716070142.GA11462@dcvr.yhbt.net \
    --to=ruby-core@ruby-lang.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

ruby-core@ruby-lang.org archive (unofficial mirror)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/ruby-core

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 ruby-core ruby-core/ https://public-inbox.org/ruby-core \
		ruby-core@ruby-lang.org
	public-inbox-index ruby-core

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.core
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.core
	nntp://news.gmane.io/gmane.comp.lang.ruby.core
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/ruby.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git