Here are some variants of the unsafe code of your original post:
Yes I know, if you look on the godbolt link there is such example, my point is that probably there will be other ways to access block which should be just a read, but can actually cause an allocation. Like
Thanks for the points. My main argument, is “yes” for most of them, I’m willing to spend time and money helping to fix it, but it’s a proposed breaking change. Maybe @kit-ty-kate has an opinion on how we could do such transition?
what do you do with third-party libraries which you cannot easily rewrite?
If they’re open source, we can propose the change, if they’re abandoned, maybe we should fork it anyway? If they’re closed source, then, yes that’s a problem and there is no good general solution that I can think of.
C bindings that deal with
floatarray need to be manually examined to rewritten to use the right C macros for accessing “flat” arrays.
unsafe code (
Obj ) needs to be carefully examined to avoid segmentation faults
Disabling the hack incurs in an automatic large time and space regression in any code that uses float array heavily.
This argument is really generic, and it only holds on because it’s already in place, if the
float array hack was being proposed we would be asking “why stop at float array?”.
But, yes I know, this only a part of the problem, this is why I proposed the tools to identify such occurrences, I didn’t propose the solution to all problems, if you don’t care about the performance, you just fix your FFI, if you care about performance you move to
As you showed, there is the possibility of automated tools to do part of the job which is really cool. I doubt that it will takes “several months of work” for most of the projects, it may had been the case for LexiFi, but as soon as we start to do it in mass the cost for each projects goes down with each new tool, like