Bug #9201

[patch] remove GC overhead for loaded_features_index

Added by Aman Gupta over 1 year ago. Updated over 1 year ago.

[ruby-core:58805]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:ruby 2.1.0dev (2013-12-02 trunk 43955) Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

I was profiling minor GC in our app and noticed 15% of time spent in mark_tbl for loaded_features_index.

The following patch removes this overhead by storing feature offsets outside the ruby heap:

https://github.com/tmm1/ruby/commit/d03c5ece865422f0510957c1dee1d33a1d9eca82


Related issues

Related to Backport200 - Backport #8048: require() features_index bloats size of ruby heap Closed 03/08/2013

Associated revisions

Revision 43974
Added by Aman Gupta over 1 year ago

  • load.c (features_index_add_single): Move loaded_features_index array values off the ruby heap. [Bug #9201]
  • load.c (loaded_features_index_clear_i): Clean up off-heap array structure.
  • vm.c (rb_vm_mark): Remove unnecessary mark_tbl for loaded_features_index. This improves minor GC time by 15% in a large application.

Revision 43974
Added by Aman Gupta over 1 year ago

  • load.c (features_index_add_single): Move loaded_features_index array values off the ruby heap. [Bug #9201]
  • load.c (loaded_features_index_clear_i): Clean up off-heap array structure.
  • vm.c (rb_vm_mark): Remove unnecessary mark_tbl for loaded_features_index. This improves minor GC time by 15% in a large application.

History

#1 Updated by Aman Gupta over 1 year ago

In features_index_add_single, we already Check_Type(offset, T_FIXNUM). This ensures these off-heap RArrays will only contain immediates and do not need to be marked.

#2 Updated by Aman Gupta over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43974.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • load.c (features_index_add_single): Move loaded_features_index array values off the ruby heap. [Bug #9201]
  • load.c (loaded_features_index_clear_i): Clean up off-heap array structure.
  • vm.c (rb_vm_mark): Remove unnecessary mark_tbl for loaded_features_index. This improves minor GC time by 15% in a large application.

#3 Updated by Aman Gupta over 1 year ago

With this patch along with the one in r43973, minor GC pauses are now up to 45% shorter in our application.

10.times{ s=Time.now; GC.start_minor; p Time.now-s }

r43972

0.034701
0.034337
0.038741
0.034126
0.037504
0.033009
0.034526
0.033238
0.034232
0.032667

r43973

0.029089
0.027402
0.027296
0.026581
0.028211
0.026294
0.028213
0.030031
0.026412
0.02695

r43974

0.024061
0.021339
0.022207
0.022007
0.022716
0.02303
0.022139
0.021704
0.022118
0.021611

#4 Updated by Yura Sokolov over 1 year ago

Look at #8158 . Don't know if it still applies, but I will fix it if you interested in.

Also available in: Atom PDF