Giter VIP home page Giter VIP logo

Comments (1)

mjebrahimi avatar mjebrahimi commented on June 11, 2024

Hi, first I recommend using other algorithms such as LZ4 or Brotli if it's possible for you because LZMA itself or maybe the current implementation (LZMA-SDK package) that EasyCompressor uses is not so efficient (both in CPU usage and Memory usage).

Just so you know, if you decide to use Brotli make sure to use the .NET built-in Brotli implementation which is included in EasyCompressor package (not the EasyCompressor.BrotliNET).

Also, make sure to use CompressionLevel.Optimal (that is by default in EasyCompressor) because the CompressionLevel.SmallestSize takes too long to process and is not cost-effective.

By the way, there is no way to throttle only a method in .NET to limit CPU or Memory usage.

But If you use orchestrators like Kubernetes or Cloud-based infrastructures you can limit your CPU Cores.

You can also limit your Entire Process through Windows by setting Process Priority to Low and Process Affinity to Minimum CPU Cores (like this or by third-party apps)

However, I think can't limit your Memory usage because if you don't have enough memory you will run into OutOfMemoryException

You can do the same using C# by setting Priority and Affinity of your Current Process or ProcessThread like this:

Process currentProcess = Process.GetCurrentProcess();

currentProcess.PriorityClass = ProcessPriorityClass.Idle; //Low

int affinityHex = 0x0002; // use only the second processor, despite availability
//affinityHex = 0x000F; // use only any of the first 4 available processors

currentProcess.ProcessorAffinity = affinityHex;

//ProcessThread processThread = currentProcess.Threads[0];
//processThread.PriorityLevel = ThreadPriorityLevel.Idle;
//processThread.ProcessorAffinity = affinityHex;

Note: The value of affinity is hex-base and you must calculate it based on which CPU Core/s you want to be available for this process. (more info and here)

from easycompressor.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.