You are here: Re: [PHP] too slow to unset big array (after mem fragment) « PHP « IT news, forums, messages
Re: [PHP] too slow to unset big array (after mem fragment)

Posted by Xuefer Tinys on 01/21/05 05:19

On Wed, 19 Jan 2005 16:28:21 -0700, kjohnson@zootweb.com
<kjohnson@zootweb.com> wrote:
>
> A question from another naive reader.
>
> Have you tried re-setting the array to an empty one, using array(),
> instead of using unset()?
indeed!, unset($arr); $arr = array();
or $arr = array(); directly
it's same :(
>
> Kirk
>




On Wed, 19 Jan 2005 14:44:10 -0800 (PST), Richard Lynch <ceo@l-i-e.com> wrote:
>
> Just some ideas from a naive reader:
>
> 1. unset() more often
i'm tracking ip of visiters to avoid double trigger of the counter.
if i shorten time to 5mins, therere so many ppl revisit after 5mins,
which give counter more points
> 2. unset() only a portion of the elements of the array
i guess so, but ..
>
> You may even want to store a TIME element, and only unset() the "old"
> items or something.
i did, but it double the size, and scan of expired elements is slower
>
> You may also want to, perhaps, put the unset() of older data inside your
> socket listening/reading loop, so that you are unset-ing the really old
> stuff as you read the new stuff, to always keep your array "small" in
> size.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
and i'm not unseting the new items
here's the logic After the slow TIME element scanning scheme:
data flow:
incomming->currentTracker->oldTracker
for .... {
$key = ...
$track = &$currentTracker[$countername][$key][$id];
if isset($currentTracker[$countername][$key][$id]):
$tarck ++;
continue; // skip trigger
elif isset($oldTracker[$countername][$key][$id]):
$track = $oldTracker[$countername][$key][$id] + 1;
continue; // skip trigger
$counts[$key] ++; // trigger, will save later
} // end for
unset($track);
expiring:
foreach 1hour:
1. unset($oldTracker); // slow
2. $oldTracker = $currentTracker; // fast, this is COW(no copy)
3. $currentTracker = array(); // fast (no efree)
if u think 2/3 is slow, i can do:
2. $oldTracker = &$currentTracker; // fast, php-reference
3. unset($currentTracker); // php-unreference
3. $currentTracker = array(); // fast
if i have to unset portion of the $oldTracker. i have to scan? or any other way?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация