unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] ruby: enable garbage collection
@ 2021-05-17 19:39 Felipe Contreras
  2021-05-17 19:39 ` [PATCH 1/2] ruby: create an actual wrapper struct Felipe Contreras
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Felipe Contreras @ 2021-05-17 19:39 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Ruby is a gc language, we shouldn't be doing workaround to free memory when Ruby is perfectly
capable of doing so.

The problem is that talloc wants to be smart, and Ruby and talloc both fight to free memory. We can
let Ruby win by stealing all the objects from talloc control.

Thanks to the previous cleanup patches it's now possible to easily do this.

In order to test this series I've used the following script:

  require 'notmuch'

  $db = Notmuch::Database.new(ENV['HOME'] + '/mail')
  $do_destroy = true

  while true
    query = $db.query('')
    threads = query.search_threads
    threads.each do |thread|
      puts '%s: %s' % [thread.thread_id, thread.subject]
      thread.destroy! if $do_destroy
    end
    threads.destroy! if $do_destroy
    query.destroy! if $do_destroy
  end

  $db.close

All threads from the database are fetched over and over with no significant increase in memory.

The old method of destroying objects with destroy! still works, but now it's not necessary.

I tried other methods, like increasing the reference counter and adding a second parent to talloc
objects, but for some reason they didn't work. I investiged why but couldn't reach any conclussion.
On the other hand the talloc_steal approach works perfectly fine.

Felipe Contreras (2):
  ruby: create an actual wrapper struct
  ruby: enable garbage collection using talloc

 bindings/ruby/database.c |  2 +-
 bindings/ruby/defs.h     | 42 +++++++++++++++++++++++++++++++++++-----
 bindings/ruby/extconf.rb |  1 +
 bindings/ruby/init.c     |  6 ++++++
 4 files changed, 45 insertions(+), 6 deletions(-)

-- 
2.31.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-07-18 22:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 19:39 [PATCH 0/2] ruby: enable garbage collection Felipe Contreras
2021-05-17 19:39 ` [PATCH 1/2] ruby: create an actual wrapper struct Felipe Contreras
2021-07-18 22:58   ` David Bremner
2021-05-17 19:39 ` [PATCH 2/2] ruby: enable garbage collection using talloc Felipe Contreras
2021-06-11  0:46   ` David Bremner
2021-06-11  8:54     ` David Bremner
2021-06-26 19:07       ` Felipe Contreras
2021-06-26 19:54         ` David Bremner
2021-06-26 20:05           ` Felipe Contreras
2021-06-26 18:56     ` Felipe Contreras
2021-06-26 19:56       ` David Bremner
2021-05-22 10:49 ` [PATCH 0/2] ruby: enable garbage collection David Bremner
2021-05-28  3:10   ` Felipe Contreras
2021-06-26 20:07 ` [PATCH] perf-test: add ruby test Felipe Contreras
2021-07-18 22:54   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).