From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNTNW-00068o-8D for qemu-devel@nongnu.org; Tue, 11 Mar 2014 16:34:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNTNR-0007j5-Eb for qemu-devel@nongnu.org; Tue, 11 Mar 2014 16:34:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNTNR-0007iz-5V for qemu-devel@nongnu.org; Tue, 11 Mar 2014 16:34:17 -0400 From: Juan Quintela In-Reply-To: <1394542415-5152-4-git-send-email-arei.gonglei@huawei.com> (arei gonglei's message of "Tue, 11 Mar 2014 20:53:28 +0800") References: <1394542415-5152-1-git-send-email-arei.gonglei@huawei.com> <1394542415-5152-4-git-send-email-arei.gonglei@huawei.com> Date: Tue, 11 Mar 2014 21:34:09 +0100 Message-ID: <87ob1c3266.fsf@elfo.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 03/10] XBZRLE: optimize XBZRLE to decrease the cache missing Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: ChenLiang , weidong.huang@huawei.com, qemu-devel@nongnu.org, owasserm@redhat.com, pbonzini@redhat.com wrote: > From: ChenLiang > > Avoid the hot pages being replaced by others to remarkable decrease cache > missing. The counter of updating dirty bitmap is used to indicate the cached > page age. > > Signed-off-by: ChenLiang > Signed-off-by: Gonglei > /** > * get_cached_data: Get the data cached for an addr > @@ -60,13 +62,15 @@ uint8_t *get_cached_data(const PageCache *cache, uint64_t addr); > * cache_insert: insert the page into the cache. the page cache > * will dup the data on insert. the previous value will be overwritten > * > - * Returns -1 on error > + * Returns -1 when the page isn't be inserted into cache s/be//? > * > * @cache pointer to the PageCache struct > * @addr: page address > * @pdata: pointer to the page > + * @current_age indicate the age of the page if the page is inserted into cache missing colon. * @current_age: current bitmap generation > @@ -161,6 +171,11 @@ int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata) > /* actual update of entry */ > it = cache_get_by_addr(cache, addr); > > + if ((it->it_data != NULL) && (it->it_age + > + CACHED_PAGE_LIFETIME > current_age)) { > + /* the cache page is fresh, don't replace it */ Should we add a counter for this "misses"? It is a question to know how much it happens. BTW, do you have any benchmark/numbers showing that this is a good idea? Thanks, Juan.