Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does composer need so much memory?

Tags:

composer-php

I recently had an issue with composer, while I was installing a symfony2 bundle.

The free memory on my VM was 700M, but it wasn't enough. It only worked after I stopped some services and freed 1.2G.

Composer documentation doesn't specify much about this:

Note: Composer internally increases the memory_limit to 512M. If you have memory issues when using composer, please consider creating an issue ticket so we can look into it.

My question is - what does composer do internally that uses so much memory ?

In my mind, the process is fairly simple, basically check dependencies between modules, then download module archives, and modify certain files. I presume the algorithms to negotiate a version of all the modules with X stability aren't simple at all, but is this a common problem between package managers for other programming languages, or is it a composer optimization issue ? (I haven't heard of such problems with RubyGems, for example).

like image 215
Vlad Preda Avatar asked Sep 10 '13 13:09

Vlad Preda


People also ask

Why do we need memory in neural networks?

Memory in neural networks is required to store input data, weight parameters and activations as an input propagates through the network. In training, activations from a forward pass must be retained until they can be used to calculate the error gradients in the backwards pass.

Why combine memory and processing resources in a single device?

Combining memory and processing resources in a single device has huge potential to increase the performance and efficiency of DNNs as well as others forms of machine learning systems.

Why does it take so much memory to install a package?

The memory isn't needed for install, the solver has to analyze a lot of packages for an update. Adding a package usually picks the latest version, over time as new versions are released, the new packages are potential candidates.

What is the relationship between constraints and memory usage?

Generally the looser the constraints, the more memory it takes to evaluate the potential candidates in between. Sorry, something went wrong. @sbuzonas Thanks, that's helpful.


1 Answers

Most other dependency managers don't have complete SAT solver and do "approximations" which require much less comparisons (so less cpu, less memory) but in some cases can yield invalid results or unsolvable things where package managers like bower will ask you what you want to do. The Composer solver usually finds a solution or conclusively finds a conflict.

So in short this is a design choice, but I realize this is also a problem due to the memory usage. There are a few strategies that should result in lower memory usage, but they are time-consuming things to even try and not many people have enough project-knowledge or time to make this happen, so it's kinda stalled at the moment.

like image 179
Seldaek Avatar answered Nov 03 '22 00:11

Seldaek