ID:1081432
 
Keywords: dll, memory
I wonder if there is a way to fast set some variables of datum via external dll, something like direct memory access by recoding \ref into memory offsets? Or any advice on how to make that fast.
I have datum with dozen of numerical vars, half of tiles in the world have own instance of this datum, I need to send most of values of each datum to the external dll, make some calculations on them (that part is lightning fast), set results back into game (that is most slow part for me, i think that is because of lots of string<->number conversions and searching for datums by reference).
I wish dll support would be more like JNI...
Ohh errr .... well, that's a funny one. I'd of course advise against anything where your plan is to do direct memory write access on BYOND's heap, because you're relying on stuff that BYOND can freely change internally. Not to mention, it take squite a bit of understanding of the VM's data-structures.

But at present, I'm not really aware of anyone doing what you'd like to do, in terms of DLLs setting datum values, aside from the string <--> number conversion you mention via call(). I'd anticipate that's possibly slower than doing the calculation in DM itself also, but I guess you've evaluated that the DLL approach was quicker than native with the overheads included. There's not really another way.

As a matter of curiosity, what exactly are you doing that requires this?
I am just trying to make air in space station 13 to calculate faster, because it sometimes take too much time to calculate so the server lags to unplayable state...
It's possible but you'll have to do a lot research on BYOND's data structures. In my opinion not worth it.
I wish developers would make some ways to do what I want from libs... Few functions like GetObjByRef(char *) and GetVarPtr(char *) in it...