mikelpapamike wrote: ↑Tue Mar 15, 2022 11:07 am
I just did a test build without the part of socket connection, just saving out static data of a field to a .json file and then running the 2x batch that correct the json data and convert it to XML.
Thank you for running the test. Quantifying things is usually helpful for diagnostics.
In task manager I see coming and going as a sub process the windows script host execution so I may assume it is the "launch commands" of batch files?
That seems correct.
So the rest ~10-12% of usage comes from the socket part?
If the only change was commenting the socket comms, the overhead of those comms would appear to account for the difference.
Also in another application, I noticed that the livecode standalone used only and maxed out one of the processors and the rest where in idle.
How can I build a standalone app that is multi-threaded?
What do you want to accomplish with threading?
Have you used threading in other languages?
My questions are in earnest. I've seen a good many requests for threading over the years, but once we examine the goal we find that threading would do little if anything to satisfy the goal in most cases.
Multithreading send to have taken on a sort of folklorish role as a universal panacea. In some cases (like smoothly animating GIFs while other actions are happening) it's exactly what's needed. But not often. And threading adds complexity to code, requiring a certain amount of additional overhead to manage them, both in the engine and by the developer. And threading introduces the potential for race conditions and other side effects single-threaded engines usually avoid. And of course the throughput of any task distributed across threads is still bound by Amdahl's Law, so results are rarely as glamorous as imagined.
To answer your question, like most scripting languages LiveCode is single-threaded.
That said, it has async options for some tasks, including socket I/O, which offload much of the handling to the OS. Sometimes that's useful. Once in a while profoundly useful. Other times it adds complication with little benefit. That's why I ask about goals.
And most code can be optimized. Sometimes a lot. Lean execution can sometimes be dramatic enough to make the thought of threading just go away. We've seen cases in these forums of code optimized by more than two orders of magnitude, sometimes more. Occasionally much more.
And if
concurrent execution (the one thing threads actually provide for their tradeoffs) is truly essential, LiveCode can be used to build mutiprocessing solutions, a pool of worker standalones happily churning away on big tasks. The overhead of multiprocessing is not much greater than multithreading on Linux, though multiprocessing on Windows does come at a greater resource cost.
Let's learn more about what you're looking to do, and that will allow us to guide you down the most productive path for what you're working on.