Hello Clément,

Am 29.05.2014 um 17:23 schrieb Clément Bera <bera.clem...@gmail.com>:
> NativeBoost is clearly the best option because it is the fastest, it is 
> mostly implemented in the image so you can look at the code and it is by 
> default in the image.
> 
> FFI from the VM typically manages much better callbacks, so if you plan to 
> extensively use callbacks you should look at it, by loading the package of 
> Aliens (It does not rely any more on the old implementation of aliens but 
> still have the same image side API and library). Alternatively you can 
> improve NativeBoost so it manages better call back, this is "easy" as it is 
> mostly implemented in the image.

Could you explain why FFI is better at managing callbacks? I have used 
NativeBoost or implementing JNIPort, and callbacks were one of the easier parts 
of the work I had to do. As far as I know, both FFI and NativeBoost don’t 
support callbacks from threads other than the thread in which the Smalltalk 
code is executed, but that’s a limitation of both of them.

As to improving NativeBoost: That’s not „easy“ at all. Some parts of it are 
quite cryptic if you are not familiar with x86 assembler code, the 
documentation is still sparse, and I am under the impression that there are 
some unfinished parts. It is practically impossible to add something to 
NativeBoost if you are not Igor, and just want to use it for your own project 
as opposed to spending many hours trying to figure out how NativeBoost works. I 
was somewhat lucky that I found everything I needed in the archives of the 
pharo-dev and pharo-users mailing list., but i wouldn’t call this documentation.

> I explained how to compile and bind a dll with NativeBoost here (subsection 
> Implementing the FFI calls) :
> http://clementbera.wordpress.com/2013/06/19/optimizing-pharo-to-c-speed-with-nativeboost-ffi/
> It is a very basic but very simple example.

Yes, this page helped, but as you wrote: basic and simple example - the more 
involved stuff remains undocumented. When working on JNIPort, I struggled with 
simple things like de-referencing a pointer to a pointer to a struct etc. - I 
didn’t find documentation for this, and this is a basic feature in my opinion. 

Best regards,
Joachim Geidel

> Additional examples can be found in the class NBBasicExamples in the package 
> NativeBoost-Examples.
> There are also tests (For example NBFFICallbackTests>>#benchQSort) that you 
> can look at, they work and show how to use NativeBoost.
> 
> Else there is the chapter in Pharo for the entrerprise. Other people will 
> give you a link.
> 

Reply via email to