Project

General

Profile

Actions

Feature #641

closed

GC patch to cache the most recent heap for is_pointer_to_heap

Added by rogerdpack (Roger Pack) about 16 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
[ruby-core:19301]

Description

=begin
This patch seems benign and speeds up gc a bit.
In a completely contrived test [meant to hammer the GC]:

require 'benchmark'
require 'pp'
a = []
1_000_000.times { a << [3] }
pp Benchmark.measure { 33.times { GC.start }}

speed went from
@real=1.99618101119995,

to
@real=1.75,

[I think Hongli does something similar with bit field lookups]. A similar patch might work for 1.8.6
Thanks!
=end


Files

cache_latest_heap.diff (1.27 KB) cache_latest_heap.diff rogerdpack (Roger Pack), 10/12/2008 03:40 PM
Actions #1

Updated by rogerdpack (Roger Pack) about 16 years ago

=begin
This appears to actually slow down 1.8.6 [but speedup 1.9--I'd guess because 1.9 has those fixed heap sizes]. in 1.8.6 TRUNK it takes 1.6s [faster, for some reason].
-=R
=end

Actions #2

Updated by authorNari (Narihiro Nakamura) about 16 years ago

=begin
Hi.

It seems interesting :)

I tried it with 1.9
But this not appeared speed up.


$ cat bm_ruby-core_19301.rb
require 'benchmark'
require 'pp'
GC::Profiler.enable
a = []
1_000_000.times { a << [3] }
pp Benchmark.measure { 33.times { GC.start }}
GC::Profiler.report

$ ./ruby-trunk/ruby bm_ruby-core_19301.rb
#<Benchmark::Tms:0x9686cb8
@cstime=0.0,
@cutime=0.0,
@label="",
@real=2.24389553070068,
@stime=0.0,
@total=2.2,
@utime=2.2>
GC 42 invokes.
Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)
1 0.032 539600 622592 31122 0.00000000000000028257
2 0.040 1080240 1097728 54873 0.40000000000000018874
3 0.052 1931380 1949696 97461 0.39999999999999968914
4 0.076 3469980 3489792 174447 1.20009999999999950049
5 0.124 6236160 6258688 312858 2.00020000000000042206
6 0.200 11212040 11239424 561834 4.00029999999999930083
7 0.340 20181700 20217856 1010646 6.80040000000000244285
8 0.408 20222720 20332544 1016379 6.80040000000000066649
9 0.476 20222720 20348928 1017198 6.40039999999999942304
10 0.540 20222720 20365312 1018017 6.80049999999999776890
11 0.608 20222720 20381696 1018836 6.80040000000000066649
12 0.676 20222720 20398080 1019655 6.80040000000000510738
13 0.744 20222720 20414464 1020474 6.00039999999999817959
14 0.804 20222720 20430848 1021293 6.80040000000000244285
15 0.872 20222720 20447232 1022112 6.40039999999999675850
16 0.936 20222720 20463616 1022931 6.40040000000000652847
17 1.000 20222720 20480000 1023750 6.00039999999999906777
18 1.060 20222720 20496384 1024569 6.80040000000000333102
19 1.128 20222720 20512768 1025388 6.40040000000000919300
20 1.192 20222720 20529152 1026207 6.40039999999999054126
21 1.256 20222720 20545536 1027026 6.40039999999999675850
22 1.320 20222720 20561920 1027845 6.80040000000000066649
23 1.388 20222720 20578304 1028664 6.40040000000000475211
24 1.452 20222720 20594688 1029483 6.80050000000000931522
25 1.520 20222720 20611072 1030302 7.20040000000000013358
26 1.592 20222720 20627456 1031121 6.80040000000000333102
27 1.660 20222720 20643840 1031940 6.40040000000000919300
28 1.724 20222720 20660224 1032759 6.80049999999999155165
29 1.792 20222720 20676608 1033578 6.40040000000000297575
30 1.856 20222720 20692992 1034397 6.80040000000000777192
31 1.924 20222720 20709376 1035216 6.80039999999999000835
32 1.992 20222720 20725760 1036035 6.80039999999999977831
33 2.060 20222720 20742144 1036854 6.80049999999998178168
34 2.128 20222720 20758528 1037673 6.80039999999999356106
35 2.196 20222720 20774912 1038492 6.80040000000002020641
36 2.264 20222720 20791296 1039311 6.40040000000000208757
37 2.328 20222720 20807680 1040130 7.20049999999998480149
38 2.400 20222720 20824064 1040949 6.80039999999999711378
39 2.468 20222720 20840448 1041768 6.80039999999998023839
40 2.536 20222720 20856832 1042587 7.20050000000000522959

$ ./ruby1.9_cach/ruby bm_ruby-core_19301.rb
#<Benchmark::Tms:0x9686c2c
@cstime=0.0,
@cutime=0.0,
@label="",
@real=2.26782369613647,
@stime=0.01,
@total=2.26,
@utime=2.25>
GC 42 invokes.
Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC Time(ms)
1 0.032 539940 622592 31122 0.39999999999999991118
2 0.044 1080320 1097728 54873 0.40000000000000007772
3 0.056 1931440 1949696 97461 0.40010000000000034426
4 0.084 3470040 3489792 174447 1.20009999999999950049
5 0.132 6236240 6258688 312858 2.00010000000000021103
6 0.220 11212100 11239424 561834 3.60020000000000006679
7 0.376 20181760 20217856 1010646 6.40039999999999764668
8 0.440 20222580 20332544 1016379 6.40039999999999764668
9 0.504 20222580 20348928 1017198 6.80049999999999688072
10 0.572 20222580 20365312 1018017 6.80039999999999800195
11 0.640 20222580 20381696 1018836 7.20040000000000279812
12 0.712 20222580 20398080 1019655 6.80049999999999510436
13 0.780 20222580 20414464 1020474 6.80039999999999711378
14 0.848 20222580 20430848 1021293 6.40040000000000031122
15 0.912 20222580 20447232 1022112 6.40039999999999498215
16 0.976 20222580 20463616 1022931 6.80040000000000333102
17 1.044 20222580 20480000 1023750 6.80039999999999711378
18 1.112 20222580 20496384 1024569 7.20050000000000167688
19 1.184 20222580 20512768 1025388 6.80039999999999089653
20 1.252 20222580 20529152 1026207 6.80039999999999533742
21 1.320 20222580 20545536 1027026 7.20049999999999990052
22 1.392 20222580 20561920 1027845 6.80039999999999000835
23 1.460 20222580 20578304 1028664 6.80039999999999356106
24 1.528 20222580 20594688 1029483 7.20049999999999812417
25 1.600 20222580 20611072 1030302 7.20039999999998858726
26 1.672 20222580 20627456 1031121 6.40039999999999231761
27 1.736 20222580 20643840 1031940 7.20049999999999723599
28 1.808 20222580 20660224 1032759 6.80040000000000954827
29 1.876 20222580 20676608 1033578 6.80039999999999267288
30 1.944 20222580 20692992 1034397 6.80050000000000132161
31 2.012 20222580 20709376 1035216 6.80040000000001310099
32 2.080 20222580 20725760 1036035 7.20039999999999569269
33 2.152 20222580 20742144 1036854 6.40040000000002162750
34 2.216 20222580 20758528 1037673 6.80050000000000398614
35 2.284 20222580 20774912 1038492 6.40040000000001718661
36 2.348 20222580 20791296 1039311 7.20040000000000013358
37 2.420 20222580 20807680 1040130 6.80039999999998112656
38 2.488 20222580 20824064 1040949 6.80050000000000753886
39 2.556 20222580 20840448 1041768 6.80040000000002020641
40 2.624 20222580 20856832 1042587 6.80040000000000244285

=end

Actions #3

Updated by rogerdpack (Roger Pack) about 16 years ago

=begin
Trying it on Linux I get about the difference between 1.84s [current gc.c] and 1.83s [patched].

I think that we can see more difference if we use more memory. Changing the test file's line
1_000_000.times { a << [3] }
to be
10_000_000.times { a << [3] }

on Linux for me this shows
new:
@real=17.7093026638031,

normal:
@real=18.3347587585449

so...overall I'd call it a small improvement.
Some things to note: you may have to run the test files several times to get a "best" result, and also [note to myself] I always have to run make install after making changes because for some reason it relies on previously installed libraries, despite the local code being different.
Thanks!
-=Roger
=end

Actions #4

Updated by ko1 (Koichi Sasada) about 16 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

Actions #5

Updated by yugui (Yuki Sonoda) about 16 years ago

  • Target version set to 2.0.0

=begin

=end

Actions #6

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

  • Status changed from Open to Assigned

=begin

=end

Updated by mame (Yusuke Endoh) almost 13 years ago

  • Status changed from Assigned to Rejected
  • Assignee changed from matz (Yukihiro Matsumoto) to authorNari (Narihiro Nakamura)

Hello,

I'm rejecting this feature ticket because no progress has been made
for a long time. See [ruby-core:42391].

Nari, are you willing to treat this ticket? If you are, please
reopen this. Maybe because lazy sweeping was imported, the patch
does not work now and it seems not to be trivial to fix it.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0