Significant decrease in throughput with cfinalizer of ForeignPtr
ForeignPtr and cfinalizer are essential for handling c++ objects with ghc.
However using cfinalizer cuts the throughput in half.
ghc version is 9.4.2.
https://github.com/junjihashimoto/ffi-benchmark
In this example, ForeignPtr_ without cfinalizer takes 60ns, and ForeignPtr with cfinalizer takes 150ns.
I tried to eliminate the influence of the internal weak pointer lock, but it(CForeignPtr without lock) takes 130ns.
I think there is also an influence of gc, but is it possible to reduce this overhead?
This is an image capture of the criterion in the above repository.
ForeignPtr_ does not use cfinalizer. It's a typo.

issue