Finalizers defined via define_finalizer are a huge performance hit

46 views
Skip to first unread message

Asmod4n

unread,
Sep 26, 2014, 4:18:09 PM9/26/14
to ruby...@googlegroups.com
Am writing a wrapper for https://github.com/zeromq/czmq and was wondering why it was 20 times slower than https://github.com/methodmissing/rbczmq.

The Culprit is ObjectSpace.define_finalizer, when i free the memory manually its only 2 times slower.

Should this be "fixed" in ruby-ffi or in ruby itself?

Matijs van Zuijlen

unread,
Sep 30, 2014, 3:40:41 AM9/30/14
to ruby...@googlegroups.com
Hi Asmd4n,

Can you give a small code sample that demonstrates the difference? I really need
to get started on memory management for my own FFI-based gem, so I'm interested
to know what works or doesn't work.

Regards,
Matijs
--
Matijs


signature.asc

Asmod4n

unread,
Sep 30, 2014, 11:58:16 AM9/30/14
to ruby...@googlegroups.com

Matijs van Zuijlen

unread,
Oct 16, 2014, 4:07:28 AM10/16/14
to ruby...@googlegroups.com
Hi Asmod4n,

That is a big difference. My first guess would be there is significant overhead
in the define_finalizer mechanism. I'll be investigating this further.

On 30/09/14 17:58, Asmod4n wrote:
> Have made a small gist for it.
>
> https://gist.github.com/Asmod4n/ccb86462a727061801de
>
> Am Dienstag, 30. September 2014 09:40:41 UTC+2 schrieb Matijs van Zuijlen:
> [...]
>
> Can you give a small code sample that demonstrates the difference?
>
> [...]


--
Matijs

signature.asc
Reply all
Reply to author
Forward
0 new messages