Answer the question
In order to leave comments, you need to log in
Does file copy speed in Ubuntu depend on RAM?
Ubuntu Xenial, Apache/2.4.6 PHP/5.6.27
.htaccess
php_value max_execution_time 9999999
php_value memory_limit 4232M I
copy about 150 files with an average size of 10kb I
copy with the function exec("cp '$src' '$dst'", $output, $ retrun_var);
If at the time of copying data is loaded into the RAM, the copying speed drops sharply (20 MB is busy - the copy speed of all files is about 10 seconds, 120 MB is busy - the copy speed increases to 40 seconds). The copy function has nothing to do with this "large" amount of data.
copy function
function copy($src, $dst) {
$files = scandir($src);
foreach ($files as $file)
{
if($file == "." || $file == "..") continue;
$oldFullName = $src. DIRECTORY_SEPARATOR .$file;
$newFullName = $dst. DIRECTORY_SEPARATOR .$file;
exec("cp '$oldFullName' '$newFullName'", $output, $retrun_var);
if($retrun_var != 0) return false;
}
return true;
}
Answer the question
In order to leave comments, you need to log in
Generally speaking, if there is enough RAM, then the actual write can take place later than the program is told "done" (the result of the execution is returned), since the cache will be used. If there is not enough cache space for all the data being written, then the result will be returned later, and part of the data will need to be written without caching, waiting for the disk subsystem to return the result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question