[MB-4738] compile ep-engine on windows with tcmalloc ( memory accoutning issues in windows when node is actively ejecting items when it reaches low watermark ( delta between mem_used and OS reported allocated memory up to 4 GB )) Created: 01/Feb/12  Updated: 31/Jan/14  Resolved: 17/Feb/12

Status: Closed
Project: Couchbase Server
Component/s: couchbase-bucket
Affects Version/s: 1.6.5.4, 1.7.1, 1.7.1.1, 1.7.2, 1.8.0
Fix Version/s: 1.8.1, 2.0-beta
Security Level: Public

Type: Bug Priority: Blocker
Reporter: Farshid Ghods (Inactive) Assignee: Bin Cui
Resolution: Fixed Votes: 0
Labels: 1.8.1-release-notes
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: windows 2008 64-bit
15 GB ram
8 B ram

Attachments: PDF File mem-usage-issue-windows.pdf     Microsoft Word report_memories_perf_on_windows_at_dgm.docx    

 Description   
this happens because memcached in windows is not using tcmalloc implementation and memcached process is not releasing the memory which was allocated before.



 Comments   
Comment by Farshid Ghods (Inactive) [ 05/Feb/12 ]
this happens when node has to eject items when it reaches the low and high water mark

the mem_used reports 6 GB but OS reports that memcached.exe process is using 10GB .

we dont have enough evidence that this happens during rebalancing but ejection and disk fetch increase the swap usage and memcached.exe memory usage.
Comment by Farshid Ghods (Inactive) [ 05/Feb/12 ]
Thuan has put this report together by running mcsoda load against 3 node cluster where each node has 15 GB ram and resident ratio drops from 70->60%

Comment by Chiyoung Seo [ 05/Feb/12 ]
Our memory accounting stat "mem_used" is incremented or decremented within the constructor / deconstructor of Blob value class that are automatically invoked when memory is allocated or deallocated. Therefore, if "mem_used" stat shows 6GB while memcached resident memory is 10GB, this means that even if we explicitly release memory to the windows memory allocator, the allocator doesn't use these freed memory areas. This is mostly caused by memory fragmentation issues on the windows default allocator.
Comment by Bin Cui [ 17/Feb/12 ]
Integrate tcmalloc with memcached and ep-engine on cygwin/mingw build environment. It will dramatically reduce the memory fragementation issue found on windows.
Comment by Steve Yen [ 20/Feb/12 ]
Adding this here, because I know I'll never be able to find this again in my webmail....

> Trond,
>
> I didn't hear about this possibility before
> Regardless , Is that something I can do during the runtime or we have
> to recompile epengine with that option ?
> If you have the binary compiled with that option I can run some tests
> on it today to confirm standard malloc itself is sufficient
>

I believe all you need to do is to export two variables at runtime:
./ns_server/couchbase-server.sh.in:GLIBCPP_FORCE_NEW=1
./ns_server/couchbase-server.sh.in:export GLIBCPP_FORCE_NEW
./ns_server/couchbase-server.sh.in:GLIBCXX_FORCE_NEW=1
./ns_server/couchbase-server.sh.in:export GLIBCXX_FORCE_NEW

Trond


> Farshid
>
> On Feb 17, 2012, at 11:32 PM, Trond Norbye <trond.norbye@couchbase.com> wrote:
>
>> Did we ever try running the test with the standard malloc and using the FORCE_NEW flag? I've asked this question a number of times now, but I haven't gotten an answer yet. Replacing the standard memory allocator with tcmalloc didn't solve the problem itself, so it seemed that it root of the problem was the memory allocator inside the C++ layer.
>>
>> From the experiments we've had during the integration it didn't feel that the windows support was that mature and well tested. It feels a bit "risky business" to me to give a version to a customer where we change such a central component on platform with so little testing. I would personally sleep way better at night using Microsofts memory allocator if it solves the problem.
>>
>> just my 0.5 nok
>>
>> trond
Comment by Dipti Borkar [ 20/Mar/12 ]
Memory accounting is required on 1.8.1
Comment by Thuan Nguyen [ 17/Apr/12 ]
Integrated in github-ep-engine-2-0 #254 (See [http://qa.hq.northscale.net/job/github-ep-engine-2-0/254/])
    Revert "MB-4738 Have tcmalloc support for windows" (Revision bb54125fc68628f29dc4ced156cdf3d8729ef2ec)

     Result = SUCCESS
Bin Cui :
Files :
* win32/Makefile.mingw
Generated at Tue Sep 23 09:09:51 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.