lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
357 stars 51 forks source link

Advanced usage help required (system resource) #136

Closed roshan-g20 closed 10 months ago

roshan-g20 commented 10 months ago

Coming directly to point, how do I use calc with number of threads I want to set and same with memory and swap, like we set it in some other CMD utilities like in (ffmpeg -i xxxxx -threads 8) or in imagemagick edit the policy.XML file and set resource values like number of threads or Ram swap etc, I've installed calc from the official distro repo, I'm not much into CLI things, but I find calc to be useful in some cases, the only fact is I don't know what and how much resources does it use. So, I'd like to know how do I set parameters for system resources after installing calc while doing calculations thanks

lcn2 commented 10 months ago

Coming directly to point, how do I use calc with number of threads I want to set and same with memory and swap, like we set it in some other CMD utilities like in (ffmpeg -i xxxxx -threads 8) or in imagemagick edit the policy.XML file and set resource values like number of threads or Ram swap etc, I've installed calc from the official distro repo, I'm not much into CLI things, but I find calc to be useful in some cases, the only fact is I don't know what and how much resources does it use.

The resources used by calc depends on what you have calc calculate. Add a few small numbers together and calc will not consume much memory. Raise a lot of numbers to huge powers and you might consume a lot of memory. Do not do much file I/O other than to write a few short messages to standard output and calc will not consume much additional disk space. Use calc's file I/O facilities to write lots of calculated data and calc might consume lots of disk space. Set calc to compute the complex hyperbolic tangent of 1/2 to 50 decimal places and calc will not consume much CPU time. Attempt to find a non-trivial integer factor of some large Mersenne number and calc and consume a huge amount of CPU time. Put calc into an infinite loop printing more and more decimal digits of pi and somewhere between a lack of available memory and/or available swap and your patience calc can exhaust your resources.

We have used calc to balance our checkbook and calc used hardly any system resources. However, we have used calc as a large set of independent parallel programs, each program working on a part of a huge calculation on a very large supercomputer that, while the total set of parallel calc programs did not use much memory, nor did they write much data to disk, and yet those processes consumed a total of thousands of CPU years of processing time over a calendar span of a few years.

So, I'd like to know how do I set parameters for system resources after installing calc while doing calculations thanks

Coming directly to a point: The primary control of system sources is managed by your operating system. While calc has functions to print the amount of CPU time used, or to print the memory size of a calc variable for example, calc does NOT set a limit on the resources a calc program can use. Calc as no built in limit on the resources it can use and is only limited by the operating system and hardware resources given to it. You, and your operating system configuration, and your available hardware resources can (and will) set those limits.

Some operation systems can set disk quotas or CPU quotas for a process. If calc is just one of those processes, your operating system can set limits on resources used by calc. Moreover when a process exceeds the limits set by an operating system, what the operating system does on response (kill the process, suspend the process, etc.) depends on your operating system and your system configuration.

As this is a question of operating systems, system resource management, and system configuration, we will respectfully close this issue. We do advise that you consult with your system documentation, as well as perhaps those who built and/or maintain your system. You might ask elsewhere on a forum designed around your operating system and/or hardware for help and advice on how to manage resources used by programs (such as calc) running under it.

We realize this may not be of much direct help. As for calc: calc is a single thread program that will use a little or as much resources and you and your operating system and computer hardware will allow. How that is done depends on you and your operating system: that is beyond the scope of calc itself.