[SERVER-8276] Investigate virtual memory growth 2.2->2.3 Created: 22/Jan/13  Updated: 15/Feb/13  Resolved: 23/Jan/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.3.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

With some data in db directory:
2.2 mongod at startup: ~300mb of virtual address space
2.3.2 mongod at startup: ~1237mb of virtual address space

With empty db directory:
2.2: 126mb
2.3.2: 433mb

I tried removing FTS and rebuilding, but that only reduced the amount by about 10 mb.



 Comments   
Comment by Eric Milkie [ 23/Jan/13 ]

Investigation complete; no action taken.

Comment by Aaron Staple [ 23/Jan/13 ]

That makes sense and looks right from the code. Should I resolve this ticket?

Comment by Eric Milkie [ 23/Jan/13 ]

Thanks for the investigation. I think the local db usage is stemming from the new startup_log collection which is written at startup time.

Comment by Aaron Staple [ 23/Jan/13 ]

I haven't been able to reproduce a consistent multiplier vsize increase. On fc17 linux I just see a 309mb size increase regardless of database size, after the databases are accessed.

                         (vsize)
fc17 2.2.2 no data
aaron     8162 16.3  0.7 132520 32304 pts/1    Sl+  19:22   0:11 ./bin/mongod
fc17 2.2.2 with data
aaron     8203  5.3  0.7 131480 31792 pts/1    Sl+  19:24   0:00 ./bin/mongod
fc17 2.2.2 with data, after reading data
aaron     8203  7.7 13.6 8424916 560372 pts/1  Sl+  19:24   0:10 ./bin/mongod
 
fc17 2.3.2 no data
aaron     8376 17.7  0.9 441144 37008 pts/1    Sl+  19:27   0:11 ./bin/mongod
fc17 2.3.2 with data
aaron     8431  9.0  0.9 8736576 38004 pts/1   Sl+  19:29   0:00 ./bin/mongod
fc17 2.3.2 with data, after reading data
aaron     8547  9.5 13.4 8733528 550040 pts/1  Sl+  19:31   0:07 ./bin/mongod

The main vsize difference seems to result because 2.2.2 maps data files into virtual memory lazily, after a database is accessed. But 2.3.2 seems to map data files on startup.

After this lazy mapping difference is accounted for, there's an additional 309mb vsize difference. Inspecting the mapped regions with gdb, the main sources of this additional vsize appear to be the following:

                                         (size)
      0x7fee42378000     0x7fee46378000  0x4000000          0                     /data/db2/local.0
      0x7fee46378000     0x7fee4a378000  0x4000000          0                     /data/db2/local.0
      0x7fee4a378000     0x7fee4b378000  0x1000000          0                     /data/db2/local.ns
      0x7fee4b378000     0x7fee4c378000  0x1000000          0                     /data/db2/local.ns
      0x7fee4fc8b000     0x7fee560b8000  0x642d000          0                      /usr/lib/locale/locale-archive

Overall this accounts for about 273mb. It looks like 2.3.2 always uses a local database, requiring local.0 and local.ns to be mapped (twice). I'm not sure when locale-archive became a dependency. It seems to be a dependency as of 2.3.1, and it doesn't seem related to the addition of fts or the switch to linking v8. I don't think it's unreasonable to link against locale data.

That leaves 36mb, which I'm not going to worry about diagnosing unless necessary.

I did the initial testing on osx. There was a similar constant vsize difference, 209mb on osx.

osx 2.2.2 no data
aaron           1015   0.2  0.3  2490624  28460 s002  S+   10:52AM   0:00.17 ./bin/mongod
osx 2.2.2 with data
aaron           1079   0.1  0.3  2490624  28860 s002  R+   11:13AM   0:00.09 ./bin/mongod
osx 2.2.2 with data, after reading data
aaron           1079   0.2  6.6  6591248 557380 s002  R+   11:13AM   0:04.69 ./bin/mongod
 
osx 2.3.2 no data
aaron           1093   0.3  0.4  2699376  32268 s002  S+   11:17AM   0:00.18 ./bin/mongod
osx 2.3.2 with data
aaron           1097   0.2  0.4  6795376  33424 s002  S+   11:18AM   0:00.44 ./bin/mongod
osx 2.3.2 with data, after reading data
aaron           1097   0.2  6.5  6800000 546508 s002  S+   11:18AM   0:04.45 ./bin/mongod

Generated at Thu Feb 08 03:17:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.