Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3745

Allocate far fewer strings from threaded.rb

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      In the process of memory profiling an application that uses Mongoid, ersatzryan and I discovered that Mongoid's threaded.rb is responsible for generating hundreds of thousands of new strings during our test case. In fact, Mongoid's own test suite generates 1,075,171 new strings just from threaded.rb.

      Defining constant thread variable keys and memoizing stack keys drastically reduces the number of new strings allocated during typical usage, bringing the test suite total from 1,075,171 to 102.

      We're also experiencing a ~4% increase in the speed of the test suite locally.

            Assignee:
            Unassigned Unassigned
            Reporter:
            laserlemon laserlemon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: