Project

General

Profile

Feature #9963

Symbol.count

Added by David Cornu almost 2 years ago. Updated almost 2 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
[ruby-core:63257]

Description

I'd like to add a way to get the size of Ruby's symbol table. This is currently possible by using Symbol.all_symbols, however it builds a new array every time it's invoked which is pretty inefficient.

The main use case for this would be to assist in detecting accidental symbol creation.

I have a PR open (https://github.com/ruby/ruby/pull/639) that adds a Symbol.count method but this could also be added in the output of GC.stat.


Related issues

Related to Ruby trunk - Feature #11158: Introduce a Symbol.count API as a more efficient alternative to Symbol.all_symbols.size Closed

History

#1 [ruby-core:63312] Updated by Motohiro KOSAKI almost 2 years ago

I understand symbol table detection is important for tuning ruby nowadays. But as far as I know, it is just because past ruby can't gc symbols.

Now, ruby trunk has symbol GC. (https://bugs.ruby-lang.org/issues/9634).
So, symbol table size is no longer important tuning parameter.

If you have another use case, please elaborate more detail.

#2 [ruby-core:63324] Updated by David Cornu almost 2 years ago

Now, ruby trunk has symbol GC

Fantastic!

#3 [ruby-core:63652] Updated by Hiroshi SHIBATA almost 2 years ago

  • Status changed from Open to Feedback

#4 Updated by Akira Tanaka 12 months ago

  • Related to Feature #11158: Introduce a Symbol.count API as a more efficient alternative to Symbol.all_symbols.size added

Also available in: Atom PDF