📃 Lua Alpha

General discussion and feedback on Second Life's SLua Alpha
lsl-luau discrepancy with mono: register exhaustion with concatenation & possible performance issue of list string casting
While trying to stress test / benchmark a comparison for (string) list and llDumpList2String , I came across a register exhaustion for a script in lsl-luau that works in mono. I'm reporting both as one canny because I'm unsure if these are related. A) First, for the benchmark: In LSO: === list-to-string benchmark: 100 iterations x 300 items === (string)list total = 1040.432007 ms mean = 10.404320 ms llDumpList2String total = 1896.921143 ms mean = 18.969212 ms ratio (string/dump) = 0.548485x === DONE === In Mono: === list-to-string benchmark: 100 iterations x 300 items === (string)list total = 226.023000 ms mean = 2.260230 ms llDumpList2String total = 316.186000 ms mean = 3.161860 ms ratio (string/dump) = 0.714842x === DONE === In LSL-LUAU: === list-to-string benchmark: 100 iterations x 300 items === (string)list total = 2287.902000 ms mean = 22.879020 ms llDumpList2String total = 589.087000 ms mean = 5.890871 ms ratio (string/dump) = 3.883810x === DONE === === list-to-string benchmark: 100 reps x 500 items === (string)list total = 4536.675000 ms mean = 45.366750 ms llDumpList2String total = 1022.474000 ms mean = 10.224740 ms ratio (string/dump) = 4.436957x === DONE === Something about how casting a list to a string is way worse in lsl-luau. My thought was that it's likely something that could be optimized if llDumpList2String is about 4x faster already. B) Second, a test script of the discrepancy is the following default { state_entry() { integer i = 1; string s = (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i + (string)i ; llOwnerSay(s); } } It prints "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" in mono, but in lsl-luau it fails to compile with "Out of registers when trying to allocate 1 registers: exceeded limit 255" I doubt there are many real use cases where this would have an impact after switching off mono, but it is still a notable difference.
2
·
Bug
·
tracked
Provide seedable (CS)PRNG implementations to SLua scripts for predictable RNG
Having math.randomseed start a consistent pseudorandom sequence in each script when calling math.random allows saving and restoring, or transmitting any procedurally generated object simply by storing, recalling, or transmitting the seed, assuming knowledge of the procedure used to generate the object, be it an instance of a puzzle, a maze, a level in a game or whatever. Without this, one is obliged to either save, restore, and/or transmit potentially a great deal of data, or to create one's own pseudorandom number generator that does not depend on math.random. Also, when debugging a script, being able to repeat a psuedorandom sequence to get consistent results among trials can be invaluable when dealing with intermittent faults and tracking down uncommon errors. I like the idea that if math.randomseed has not been called, that the effective seed is itself random as is presently the case. Nevertheless, for the above reasons, I feel that it is valuable to be able to stipulate a seed that applies specifically to the script in question and does not affect and is not affect by sequences being generated by any other scripts concurrently running. On possible option that might be less painful than completely replacing the current implementation, could be to add a second math.rand and math.randseed pair that performed as described above, using a relatively simple, fast algorithm that might not be guaranteed to be quite as well randomized as math.random, but that is adequate for randomized procedural object generation.
2
·
Feature
·
tracked
Load More
→