El script PHP sigue haciendo mmap / munmap

Mi script PHP contiene un bucle, que no hace más que repetir y quitar punteros (como en $ tab [$ othertab [$ i]] -> cosas).

Funcionó de maravilla hasta ayer, cuando este script comenzó a ser MUY lento (como 50 veces más lento que antes).

Después de usar strace, descubrí que el 90% del tiempo, el script hace mmap / munmap. Aquí hay una porción aleatoria del registro strace:

 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 munmap (0x7fac0156c000, 266240) = 0
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac0152b000
 mmap (NULL, 266240, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) = 0x7fac014ea000

Aquí está el resultado del comando strace -c:

 % de segundos de uso de los segundos / llamada de llamadas errores syscall
 ------ ----------- ----------- --------- --------- ---- ------------
  82,77 0,004092 0 13542 mmap
   9.69 0.000479 0 3642 escribir
   7.54 0.000373 0 13541 munmap
   0.00 0.000000 0 100 leer
   0.00 0.000000 0 88 encuesta
   0.00 0.000000 0 25 4 acceso
 ------ ----------- ----------- --------- --------- ---- ------------
 100,00 0,004944 30938 4 total

Aquí está el script php:

function affAnnonce($tabAnnonces, $isDoublon = 0) { GLOBAL $db, $base, $tabDomaine, $doublon, $traduction, $tab_contrat, $tab_emploi, $tab_categ, $tab_metier, $tab_region, $tab_departement, $tab_secteur, $tab_experience, $calc_all, $tabLangues, $tabLanguesNiveau, $tabNoAffAnnonce, $tabHisto; foreach($tabAnnonces AS $tmp) { if (in_array($tmp['id'], $tabNoAffAnnonce) === true) { continue; } $value->host = "../"; foreach($tabDomaine AS $domaine => $valeur) { if ($domaine == $tmp['domaine']) { $value->host = $valeur->host; break; } } // Ordre // secteur;metier;contrat;emploi;region;langues;domaine $tabPushModif = array(); if ($tmp['push_preview'] != '') { $tabPushModif = explode(';', $tmp['push_preview']); $tabPushModif['secteur'] = $tabPushModif[0]; $tabPushModif['metier'] = $tabPushModif[1]; $tabPushModif['contrat'] = $tabPushModif[2]; $tabPushModif['id_emploi'] = $tabPushModif[3]; $tabPushModif['regions'] = $tabPushModif[4]; $tabPushModif['langues'] = $tabPushModif[5]; $tabPushModif['domaine'] = $tabPushModif[6]; } $infoSoc = get_nom_societe($tmp['id_societe']); $number = ($tmp['nb_preview_push'] != '' ? $tmp['nb_preview_push'] : ' '); $secteurs = explode ("/", $tmp[secteur]); $sector = ""; $count_sect = count($secteurs); for ($k = 0; $k < $count_sect; $k++) { if ($secteurs[$k] != '') { $sector .= $tab_secteur[$secteurs[$k]].'/'; } } $tmp['poste'] = apresinsertion($tmp['poste']); $tmp['metier'] = $tab_metier[$tmp['metier']]; $tmp['region'] = $tab_region[$tmp['region']]; $tmp['departement'] = $tab_departement[$tmp['departement']]; $tmp['secteur'] = $sector; $tmp['id_contrat'] = $tmp['contrat']; $tmp['contrat'] = $tab_contrat[$tmp['contrat']]; $tmp['emploi'] = $tab_emploi[$tmp['id_emploi']]; $tmp['categorie'] = $tab_categ[$tmp['categorie']]; echo ''.$tmp[id].'
'; echo 'host.'" target="blank">'.strtoupper($tmp['domaine']).'
'; echo ''; if ($isDoublon) echo 'DOUBLON - '; if (($tmp[id_reponse] == 1) || ($tmp[id_reponse] == 2) || ($tmp[id_reponse] == 4) || ($tmp[id_reponse] == 5)) echo 'host.'\')" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">'.$tmp['poste'].''; if ($tmp[id_reponse] == 3) echo ''.$tmp['poste'].''; if ($tmp['urgent'] == 1) print " - urgent"; if ($tmp['gold'] == 1) print " - gold"; if ($tmp['cvtheque'] == 1) print " - CVthèque"; if ($tmp['url_reponse'] != '' && $tmp['id_reponse'] != 3) { echo '

URL - '; $len = strlen($tmp['url_reponse']); if ($len > 50) { $link = substr($tmp['url_reponse'], 0, 47).'...'; } else { $link = $tmp['url_reponse']; } echo ''.$link.''; } // Début du div ou sera placé l'annonce echo '
'; $tmp["url"] = substr($tmp["url"], 7); $id_modele = getIdModeleByAnnonce($tmp['id_societe'], $tmp["id"], $tmp['domaine']); $tmp["poste"] = mb_strtoupper($tmp["poste"]); $isFnh = isFnhAnnonce($tmp['id']); $logo = ""; if ($isFnh) { $logo_jpg = getFnhLogo(); $logo = ""; } else { if ($id_modele > 0) { if ($tmp['id_reponse'] == 1) { $logo_gif = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele.".gif"; if (file_exists($logo_gif)) { $logo = ""; } } else { $rep = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele; $logo_jpg = $rep.".jpg"; $logo_swf = $rep.".swf"; $logo_gif = $rep.".gif"; if (file_exists($logo_jpg)) { $logo = ""; } elseif (file_exists($logo_swf)) $logo = ' '; elseif (file_exists($logo_gif)) { $logo = ""; } } } } if (strlen($logo) > 0 && strlen($tmp['url']) > 0) $logo = "".$logo.""; if (strlen($tmp['url_reponse']) aff_word("repondre_courrier", $tabTrad['only_word']).'\n'.$tmp['societe'].'\n'.str_replace("
", '\n', ereg_replace("[\r\n\t]", "", $tmp['adresse']))."');"; else $tmp['url_reponse'] .= "popUp(this.href, 'scroll', 540, 400);"; $tmp['url_reponse'] .= "return false;"; } ?>

aff_word("pays")?> :
aff_word("region")?> :
aff_word("departement")?> :
aff_word("ville")?> :
aff_word("debut_travail")?> :
aff_word("type_contrat")?> :
aff_word("type_emploi")?> :
aff_word("salair")?> :
aff_word("experience_metier")?> :
aff_word("reference")?> :
 
aff_word("presentation")?> :
 
aff_word("poste")?> :
 
aff_word("description")?> :
 
aff_word("profil")?> :
 
 
aff_word("contact")?> :  
 
  <a href="https://stackoverflow.com/questions/3021799/php-script-keeps-doing-mmap-munmap/" target="_blank">>> aff_word("repondre_en_ligne")?>
<a href="https://stackoverflow.com/questions/3021799/jobs/affiche_imprime_annonce.php?id=" onClick="popUp(this.href, 'scroll', 540, 400);return false;" target="_blank">>> aff_word("version_imprimer")?>
<a href="https://stackoverflow.com/questions/3021799/jobs/send_friend_annonce.php?id=" onClick="popUp(this.href, 'clean', 400, 300);return false;" target="_blank">>> aff_word("envoi_ami")?>
<a href="https://stackoverflow.com/questions/3021799/php-script-keeps-doing-mmap-munmap/affiche_liste.php?soc=">>> aff_word("toutes_offres")?>
>> aff_word("nouvelle_recherche")?>
<< aff_word("retour")?>



 
aff_word("tel")?> :
aff_word("fax")?> :
<a href="http://" target="_blank">
<? echo '
'; // Fin du div ou sera placé l'annonce echo "".date_2fr($tmp['date_creation'], 1)."
".date_2fr($tmp['date_affichage'], 1); echo "".$tmp[societe]."
(host."login/login.php?login=".$infoSoc->email."&pass=".$infoSoc->password." target=_blank>".$infoSoc->nom.")
compte"; $color = ''; switch($tmp[push_mail]) { case "0": $color = " bgcolor=#DBB7FF"; break; case "2": $color = " bgcolor=#CCCCCC"; break; default : ; } $type_rep = ""; switch ($tmp[id_reponse]) { case 1: $type_rep = "Standard"; break; case 2: $type_rep = "Chartée"; break; case 3: $type_rep = "Metamoteur"; break; case 4: $type_rep = "Reponse sur site"; break; case 5: $type_rep = "Semi-chartée"; break; } print "
".$tmp['contrat']." - ".$tmp['emploi']." Modifier push

Envoyer Push
".(strlen($tmp['metier']) > 0 ? $tmp['metier'] : ''.$tmp['categorie'].'')."
".$tmp[secteur]."
".($number < 500 ? '' : ($number > 1500 ? '' : '')).$number."
"; if (strlen($tabPushModif['regions']) > 0) { $tab = explode('/', $tabPushModif['regions']); foreach($tab AS $elem) { if (strlen($elem) getObj($query_tmp); if ($obj) { echo ' - '.$tab_region[$obj->region]; $query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"'; $obj = $db->getObj($query_tmp); if ($obj) echo ' ('.$obj->code_pays.')'; } } elseif (is_numeric($elem) === false) { echo ''.$tmp['departement'].' - '.$tmp['region'].' ('.$elem.')'; } else { echo ''.$tmp['departement'].' - '.$tab_region[$elem]; $query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"'; $obj = $db->getObj($query_tmp); if ($obj) echo ' ('.$obj->code_pays.')'; } } } else echo $tmp['departement']." - ".$tmp['region']." (".$tmp['code_pays'].")"; echo "
".$tmp[ville]."
"; if (strlen($tabPushModif['metier']) > 0) { $tmpExp = array(); $tab = explode('/', $tabPushModif['metier']); foreach($tab AS $elem) { if (strlen($elem) <= 0) continue; $tmpMetier = explode('-', $elem); if (isset($tmpMetier[1])) { if (in_array($tmpMetier[1], $tmpExp) === true) continue; $tmpExp[] = $tmpMetier[1]; if ($tmpMetier[1] == $tmp['experience']) echo ''.$tab_experience[$tmpMetier[1]].'/'; else echo $tab_experience[$tmpMetier[1]].'/'; } } if (count($tmpExp) <= 0) echo ''.$tab_experience[$tmp['experience']].''; } else echo $tab_experience[$tmp['experience']]; echo "
".$tabLangues[$tmp['id_langue']]->langue." - ".$tabLanguesNiveau[$tmp['id_langue_niveau']]->langue_niveau."
$type_rep
".$tmp[compteur_vu]." / ".$tmp[compteur_repondu]."
Modifier
Supprimer
".($tmp['affiche'] == 1 ? 'Mettre hors ligne' : 'Mettre en ligne')."

 ".nl2br($tmp['push_res']).'

'; if (is_array($tabHisto[$tmp['id']])) { echo '

'; foreach($tabHisto[$tmp['id']] as $histo) { echo $histo['type_modif'].' '.HumanDateTime($histo['date']).' par '.$histo['user']; if ($histo['new_annonce']) { echo ' [New ID : '.$histo['new_annonce'].']'; } echo '
'; } echo '

'; } echo "  ".$tmp['source']; if (!empty($tmp['source_ref'])) { echo '
Voir original'; } echo ''; if (isset($doublon) && !$isDoublon) { $query2 = " SELECT a.*, rp.pays0, rp.code_pays FROM annonces a INNER JOIN ref_pays rp ON rp.id = a.pays WHERE a.id_societe = '".$tmp['id_societe']."' AND a.contrat = '".$tmp['id_contrat']."' AND a.domaine = '".$tmp['domaine']."' AND a.id != '".$tmp['id']."' AND ADDDATE(a.date_creation, INTERVAL 2 MONTH) > '".$tmp['date_creation']."' AND a.poste = \"".addslashes($tmp['poste'])."\" AND a.ville = \"".addslashes($tmp['ville'])."\" AND a.societe = \"".addslashes($tmp['societe'])."\" AND (a.id_societe != 1 OR (a.id_societe = 1 AND a.contact_email = \"".$tab_annonce['contact_email']."\")) ORDER BY a.id DESC"; $tabAnnonces2 = $db->getTab($query2); if (count($tabAnnonces2) > 0) { $tabId = array(); foreach($tabAnnonces2 as $annonc) { $tabId[] = $annonc['id']; } $tmpListAnnonceTab = annoncelist::getHistorique($tabId); $tmpTabHisto = createTabHisto($tmpListAnnonceTab); $tabHisto += $tmpTabHisto; //Additionne les 2 tableaux, contrairment à array_merge il garde les clés !! affAnnonce($tabAnnonces2, 1); foreach($tabAnnonces2 AS $tmpAnn) $tabNoAffAnnonce[] = $tmpAnn['id']; } } } } ?>

Solo este script es lento, todos los demás en el mismo servidor / dominio / directorio funcionan bien. En otro servidor, la misma secuencia de comandos funciona bien. La secuencia de comandos toma hasta el 90% de la CPU cuando se ejecuta.

¿Algunas ideas?

Solutions Collecting From Web of "El script PHP sigue haciendo mmap / munmap"