[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...

Issue #14357 has been reported by vo.x (Vit Ondruch).

11 messages 2018/01/15

[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...

Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).

10 messages 2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...> 2018/01/23

hsbt@ruby-lang.org wrote:

[ruby-core:84672] [Ruby trunk Feature#13587][Closed] Improve performance of string interpolation

From: takashikkbn@...
Date: 2018-01-06 05:41:50 UTC
List: ruby-core #84672
Issue #13587 has been updated by k0kubun (Takashi Kokubun).

Status changed from Open to Closed
Assignee set to nobu (Nobuyoshi Nakada)

This was applied in r60320.

----------------------------------------
Feature #13587: Improve performance of string interpolation
https://bugs.ruby-lang.org/issues/13587#change-69389

* Author: south37 (Nao Minami)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
This patch will add pre-allocation in string interpolation.
By this, unnecessary capacity resizing is avoided.

For small strings, optimized `rb_str_resurrect` operation is faster, so pre-allocation is done only when concatenated strings are large.
`MIN_PRE_ALLOC_SIZE` was decided by experimenting with local machine (x86_64-apple-darwin 16.5.0, Apple LLVM version 8.1.0 (clang - 802.0.42)).

String interpolation will be faster around 72% when large string is created.

**Before**

```
Calculating -------------------------------------
Large string interpolation
                          1.276M (賊 5.9%) i/s -      6.358M in   5.002022s
Small string interpolation
                          5.156M (賊 5.5%) i/s -     25.728M in   5.005731s
```

**After**

```
Calculating -------------------------------------
Large string interpolation
                          2.201M (賊 5.8%) i/s -     11.063M in   5.043724s
Small string interpolation
                          5.192M (賊 5.7%) i/s -     25.971M in   5.020516s
```

**Test code**

```
require 'benchmark/ips'

Benchmark.ips do |x|
  x.report "Large string interpolation" do |t|
    a = "Hellooooooooooooooooooooooooooooooooooooooooooooooooooo"
    b = "Wooooooooooooooooooooooooooooooooooooooooooooooooooorld"

    t.times do
      "#{a}, #{b}!"
    end
  end

  x.report "Small string interpolation" do |t|
    a = "Hello"
    b = "World"

    t.times do
      "#{a}, #{b}!"
    end
  end
end
```

**Patch**
https://github.com/ruby/ruby/pull/1626



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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next