Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Memory use problem on FreeBSD
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Graham-Cumming  
View profile  
 More options Nov 19 2012, 4:20 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Mon, 19 Nov 2012 13:20:23 -0800 (PST)
Local: Mon, Nov 19 2012 4:20 pm
Subject: Memory use problem on FreeBSD
I have a long running Go program that allocates a large amount of
memory over time. On FreeBSD 64 bit I am seeing a problem where once I
am done with the memory the RES size as reported by top never
decreases.

For example, after my program has finished processing requests I stop
all requests and let CPU drop to 0% and then leave it so that GC and
scavenging has time to work. Then I look at the RES size in top and
dump out a memory profile for pprof. In one example, I have RES of
15666M (i.e. 15GB) and pprof showing me:

(pprof) top10
Total: 32.7 MB

This is using Go version: devel +40ba4d4e4672 Tue Nov 13 10:45:30 2012
-0800

Are there any known problem with Go not returning memory to the OS on
that version (or the bleeding edge in general)? I do not see memory
problems like this on Linux. Although the nature of my test
environment means I can't do precisely the same test on Linux and
FreeBSD because FreeBSD as it a client site.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 19 2012, 6:45 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Mon, 19 Nov 2012 15:45:48 -0800 (PST)
Local: Mon, Nov 19 2012 6:45 pm
Subject: Re: Memory use problem on FreeBSD
On Nov 19, 9:20 pm, John Graham-Cumming <jgrah...@gmail.com> wrote:

> I have a long running Go program that allocates a large amount of
> memory over time. On FreeBSD 64 bit I am seeing a problem where once I
> am done with the memory the RES size as reported by top never
> decreases.

Hmm. I think I might have found the answer to my question in
mem_freebsd.c:

void
runtime·SysUnused(void *v, uintptr n)
{
        USED(v);
        USED(n);
        // TODO(rsc): call madvise MADV_DONTNEED

}

It appears that it does not tell the OS that the memory is no longer
needed. Am I correct?

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 19 2012, 6:47 pm
From: Dave Cheney <d...@cheney.net>
Date: Tue, 20 Nov 2012 10:47:28 +1100
Local: Mon, Nov 19 2012 6:47 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
Hi John,

I was just chasing that down. You are correct that implementing this
method should activate the scavenger. I'll prepare a CL.

Cheers

Dave

On Tue, Nov 20, 2012 at 10:45 AM, John Graham-Cumming


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 19 2012, 6:51 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Mon, 19 Nov 2012 15:50:53 -0800 (PST)
Local: Mon, Nov 19 2012 6:50 pm
Subject: Re: Memory use problem on FreeBSD
On Nov 19, 11:47 pm, Dave Cheney <d...@cheney.net> wrote:

> I was just chasing that down. You are correct that implementing this
> method should activate the scavenger. I'll prepare a CL.

It looks like for xBSD (where x is Free, Net and Open) runtime.madvise
is not implemented at all.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 19 2012, 10:40 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Mon, 19 Nov 2012 19:40:32 -0800 (PST)
Local: Mon, Nov 19 2012 10:40 pm
Subject: Re: Memory use problem on FreeBSD

On Monday, November 19, 2012 11:51:04 PM UTC, John Graham-Cumming wrote:

> On Nov 19, 11:47 pm, Dave Cheney <d...@cheney.net> wrote:
> > I was just chasing that down. You are correct that implementing this
> > method should activate the scavenger. I'll prepare a CL.

> It looks like for xBSD (where x is Free, Net and Open) runtime.madvise
> is not implemented at all.

I made an experimental patch to Go on FreeBSD amd64 by adding the following
to sys_freebsd_amd64.s:

TEXT runtime?madvise(SB),7,$0                                              

        MOVQ    8(SP), DI                                                  

        MOVQ    16(SP), SI                                                

        MOVQ    24(SP), DX                                                

        MOVQ    $75, AX // madvise                                        

        SYSCALL                                                            

        CMPQ    AX, $0xfffffffffffff001                                    

        JLS     2(PC)                                                      

        MOVL    $0xf1, 0xf1  // crash                                      

        RET                          

And changing mem_freebsd.c so that it actually gets called. That worked.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 19 2012, 10:46 pm
From: Dave Cheney <d...@cheney.net>
Date: Tue, 20 Nov 2012 14:46:23 +1100
Local: Mon, Nov 19 2012 10:46 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
Yup, that is all that is needed. Do you want to propose a CL ?

Cheers

Dave


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 19 2012, 10:48 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Mon, 19 Nov 2012 19:48:33 -0800 (PST)
Local: Mon, Nov 19 2012 10:48 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

On Tuesday, November 20, 2012 3:46:37 AM UTC, Dave Cheney wrote:

> Yup, that is all that is needed. Do you want to propose a CL ?

What's needed is a CL for all the BSDs and both 32 and 64 bit. I don't have
all those systems to test against.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Devon H. O'Dell  
View profile  
 More options Nov 19 2012, 10:50 pm
From: "Devon H. O'Dell" <devon.od...@gmail.com>
Date: Mon, 19 Nov 2012 22:50:03 -0500
Local: Mon, Nov 19 2012 10:50 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
2012/11/19 John Graham-Cumming <jgrah...@gmail.com>:

> On Tuesday, November 20, 2012 3:46:37 AM UTC, Dave Cheney wrote:

>> Yup, that is all that is needed. Do you want to propose a CL ?

> What's needed is a CL for all the BSDs and both 32 and 64 bit. I don't have
> all those systems to test against.

Just for reference (in case this isn't what you've done) I'm pretty
sure that MADV_FREE is what we want on FreeBSD. (I don't know about
OpenBSD or NetBSD). MADV_DONTNEED doesn't mean the same thing on Linux
and FreeBSD.

--dho


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 19 2012, 10:50 pm
From: Dave Cheney <d...@cheney.net>
Date: Tue, 20 Nov 2012 14:50:47 +1100
Local: Mon, Nov 19 2012 10:50 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
I'd start with FreeBSD, then do the others in a later CL, generally
there is someone on the list who has hardware available to test.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 19 2012, 10:51 pm
From: Dave Cheney <d...@cheney.net>
Date: Tue, 20 Nov 2012 14:51:39 +1100
Local: Mon, Nov 19 2012 10:51 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
Yup, that matches my research,

see: https://codereview.appspot.com/6856066/

On Tue, Nov 20, 2012 at 2:50 PM, Devon H. O'Dell <devon.od...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Hartland  
View profile  
 More options Nov 20 2012, 4:22 am
From: "Steven Hartland" <kill...@multiplay.co.uk>
Date: Tue, 20 Nov 2012 09:22:36 -0000
Local: Tues, Nov 20 2012 4:22 am
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

It may be unrelated but there was a kernel memory leak in fadvise which was fixed by:-
http://svnweb.freebsd.org/base?view=revision&revision=234661

    Regards
    Steve


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 20 2012, 1:55 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Tue, 20 Nov 2012 10:55:21 -0800 (PST)
Local: Tues, Nov 20 2012 1:55 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

On Tuesday, November 20, 2012 3:51:47 AM UTC, Dave Cheney wrote:

> Yup, that matches my research,

> see: https://codereview.appspot.com/6856066/

Are you planning a CL to fix this problem?  My experiments with FreeBSD
indicate that MADV_FREE is the way to go, but I am not enough of an expert
on the BSD family to do a CL and feel confident that I have fully
understood the solution.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Devon H. O'Dell  
View profile  
 More options Nov 20 2012, 3:03 pm
From: "Devon H. O'Dell" <devon.od...@gmail.com>
Date: Tue, 20 Nov 2012 15:03:17 -0500
Local: Tues, Nov 20 2012 3:03 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
2012/11/20 John Graham-Cumming <jgrah...@gmail.com>:

> On Tuesday, November 20, 2012 3:51:47 AM UTC, Dave Cheney wrote:

>> Yup, that matches my research,

>> see: https://codereview.appspot.com/6856066/

> Are you planning a CL to fix this problem?  My experiments with FreeBSD
> indicate that MADV_FREE is the way to go, but I am not enough of an expert
> on the BSD family to do a CL and feel confident that I have fully understood
> the solution.

I think Dave was going to let you do it. We can review and make
suggestions if you'd like to continue, otherwise I'm sure Dave can
continue?

--dho


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 20 2012, 3:08 pm
From: Dave Cheney <d...@cheney.net>
Date: Wed, 21 Nov 2012 07:07:57 +1100
Local: Tues, Nov 20 2012 3:07 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

Yup. That was the plan, but if you would rather have me do it, please let
me know.
On 21 Nov 2012 07:03, "Devon H. O'Dell" <devon.od...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 20 2012, 3:09 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Tue, 20 Nov 2012 12:09:11 -0800 (PST)
Local: Tues, Nov 20 2012 3:09 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

On Tuesday, November 20, 2012 8:08:10 PM UTC, Dave Cheney wrote:

> Yup. That was the plan, but if you would rather have me do it, please let
> me know.

I'll prepare a patch and submit for FreeBSD amd64 which I have tested.
Others can expand to the other platforms.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Cheney  
View profile  
 More options Nov 20 2012, 3:14 pm
From: Dave Cheney <d...@cheney.net>
Date: Wed, 21 Nov 2012 07:14:36 +1100
Local: Tues, Nov 20 2012 3:14 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

SGTM.
On 21 Nov 2012 07:09, "John Graham-Cumming" <jgrah...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 20 2012, 3:52 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Tue, 20 Nov 2012 12:52:41 -0800 (PST)
Local: Tues, Nov 20 2012 3:52 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

Done. Patch is here: http://codereview.appspot.com/6850081

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Devon H. O'Dell  
View profile  
 More options Nov 20 2012, 4:20 pm
From: "Devon H. O'Dell" <devon.od...@gmail.com>
Date: Tue, 20 Nov 2012 16:19:48 -0500
Local: Tues, Nov 20 2012 4:19 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD
FWIW i386 should basically just be the same code; the assembler should
be simple enough to crib from elsewhere.

--dho

2012/11/20 Dave Cheney <d...@cheney.net>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Graham-Cumming  
View profile  
 More options Nov 20 2012, 4:56 pm
From: John Graham-Cumming <jgrah...@gmail.com>
Date: Tue, 20 Nov 2012 13:56:02 -0800 (PST)
Local: Tues, Nov 20 2012 4:56 pm
Subject: Re: [go-nuts] Re: Memory use problem on FreeBSD

On Tuesday, November 20, 2012 9:20:06 PM UTC, Devon H. O'Dell wrote:

> FWIW i386 should basically just be the same code; the assembler should
> be simple enough to crib from elsewhere.

Agreed. Similarly for NetBSD and OpenBSD. I'm sure they are all very
similar. I just wasn't comfortable submitting code that I had not tested.

John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »