ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:97165] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions
       [not found] <redmine.issue-16029.20190731010619.7941@ruby-lang.org>
@ 2020-02-14 14:19 ` jean.boussier
  2020-07-17  9:23 ` [ruby-core:99201] " eregontp
  2020-07-17 10:39 ` [ruby-core:99202] " jean.boussier
  2 siblings, 0 replies; 3+ messages in thread
From: jean.boussier @ 2020-02-14 14:19 UTC (permalink / raw)
  To: ruby-core

Issue #16029 has been updated by byroot (Jean Boussier).


>   it makes sense to add an official API as well that does not depend on dynamic invocation

It's not just about the dynamic invocation. Sure it's a bit slower but not a huge deal.

It's mostly that to get to that invocation you need to first allocate a duplicate string.

The ideal API would allow to pass a char* to avoid all this garbage.

For context our app loads a lot of static data from flat files (json / yaml / messagepack) for a total of over 5M objects (~25% of the allocations during boot). 80% of that ends up deduplicated later on by `String#-@`. 

I believe that if json / psych / messagepack had access to `rb_fstring_cstr`, I could avoid allocating all these useless objects and save a lot of GC time (~30% of our boot time is spent in GC, 25% marking and 5% sweeping).

----------------------------------------
Feature #16029: Expose fstring related APIs to C-extensions
https://bugs.ruby-lang.org/issues/16029#change-84271

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
As discussed with @tenderlove here: https://github.com/ruby/ruby/pull/2287#issuecomment-513865160

We'd like to update various data format parsers (JSON, MessagePack, etc) to add the possibility to deduplicate strings while parsing.

But unfortunately the `rb_fstring_*` family of functions isn't available to C-extensions, so the only available fallback is `rb_funcall(str, rb_intern("-@"))` which most parsers will likely consider too slow. So the various `rb_fstring_*` functions would need to be public.

Proposed patch: https://github.com/ruby/ruby/pull/2299



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:99201] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions
       [not found] <redmine.issue-16029.20190731010619.7941@ruby-lang.org>
  2020-02-14 14:19 ` [ruby-core:97165] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions jean.boussier
@ 2020-07-17  9:23 ` eregontp
  2020-07-17 10:39 ` [ruby-core:99202] " jean.boussier
  2 siblings, 0 replies; 3+ messages in thread
From: eregontp @ 2020-07-17  9:23 UTC (permalink / raw)
  To: ruby-core

Issue #16029 has been updated by Eregon (Benoit Daloze).


See https://bugs.ruby-lang.org/issues/13381#note-6

----------------------------------------
Feature #16029: Expose fstring related APIs to C-extensions
https://bugs.ruby-lang.org/issues/16029#change-86580

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
As discussed with @tenderlove here: https://github.com/ruby/ruby/pull/2287#issuecomment-513865160

We'd like to update various data format parsers (JSON, MessagePack, etc) to add the possibility to deduplicate strings while parsing.

But unfortunately the `rb_fstring_*` family of functions isn't available to C-extensions, so the only available fallback is `rb_funcall(str, rb_intern("-@"))` which most parsers will likely consider too slow. So the various `rb_fstring_*` functions would need to be public.

Proposed patch: https://github.com/ruby/ruby/pull/2299



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:99202] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions
       [not found] <redmine.issue-16029.20190731010619.7941@ruby-lang.org>
  2020-02-14 14:19 ` [ruby-core:97165] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions jean.boussier
  2020-07-17  9:23 ` [ruby-core:99201] " eregontp
@ 2020-07-17 10:39 ` jean.boussier
  2 siblings, 0 replies; 3+ messages in thread
From: jean.boussier @ 2020-07-17 10:39 UTC (permalink / raw)
  To: ruby-core

Issue #16029 has been updated by byroot (Jean Boussier).


Yes I saw it this morning. Now that it's assigned and likely to be merged soon. We can probably close this issue as duplicate.

----------------------------------------
Feature #16029: Expose fstring related APIs to C-extensions
https://bugs.ruby-lang.org/issues/16029#change-86581

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
As discussed with @tenderlove here: https://github.com/ruby/ruby/pull/2287#issuecomment-513865160

We'd like to update various data format parsers (JSON, MessagePack, etc) to add the possibility to deduplicate strings while parsing.

But unfortunately the `rb_fstring_*` family of functions isn't available to C-extensions, so the only available fallback is `rb_funcall(str, rb_intern("-@"))` which most parsers will likely consider too slow. So the various `rb_fstring_*` functions would need to be public.

Proposed patch: https://github.com/ruby/ruby/pull/2299



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-17 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16029.20190731010619.7941@ruby-lang.org>
2020-02-14 14:19 ` [ruby-core:97165] [Ruby master Feature#16029] Expose fstring related APIs to C-extensions jean.boussier
2020-07-17  9:23 ` [ruby-core:99201] " eregontp
2020-07-17 10:39 ` [ruby-core:99202] " jean.boussier

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).