OCaml Bigarray: slower than embedded arrays?

What are the disadvantages of using Bigarray when interacting with C is not a problem? Are they slower in particular for small 2D matrices?

+4
source share
2 answers

Just based on viewing implementations, I would say that bigarrays can be slower if you create a large number of short-lived arrays. It seems that the memory for them is managed outside the usual OCaml GC, which handles short-lived objects very well.

You may also find that calls to bigarrays are not included, while access to inline arrays will be.

On the other hand, inline arrays will have additional indirection for two dimensions.

If performance really matters, you may have to test your specific application.

+6
source

The main disadvantage of this type is that bigarrays can contain only a small subset of primitive types.

+3
source

Source: https://habr.com/ru/post/1442775/


All Articles