From f9117072fb0cf80263a9a94eb6c245cca49a6b93 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 16 Sep 2012 20:36:02 -0700 Subject: [PATCH] Describe undesirable but necessary cruft --- cruft.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cruft.md diff --git a/cruft.md b/cruft.md new file mode 100644 index 00000000..3de9d682 --- /dev/null +++ b/cruft.md @@ -0,0 +1,19 @@ +As of Ruby 1.9.3, it is impossible to dynamically generate a Symbol +through interpolation without generating garbage. Theoretically, Ruby +should be able to take care of this by building up the String in C and +interning the C String. + +Because of this, we avoid generating dynamic Symbols at runtime. For +example, instead of generating the instrumentation event dynamically, we +have a constant with a Hash of events: + +```ruby +INSTRUMENT = { + :serialize => :"serialize.serializer", + :associations => :"associations.serializer" +} +``` + +If Ruby ever fixes this issue and avoids generating garbage with dynamic +symbols, this code can be removed. +