#1523 closed defect

MDMF upload via web-API uses much more memory in the gateway process than expected — at Version 8

Reported by: davidsarah Owned by: davidsarah
Priority: major Milestone: undecided
Component: code-frontend-web Version: 1.9.0a1
Keywords: mdmf memory-leak tahoe-put performance Cc:
Launchpad Bug:

Description (last modified by davidsarah)

Split from #113:

The web-API interface does not support streaming (#113, #320), so it is expected for the gateway to need to hold the whole file in memory in order to upload it. However, when using tahoe put to upload an MDMF file, the increase in memory usage of the gateway process seems to be much larger than the file size. For example, when uploading a 191 MiB MDMF file in 1.9alpha using tahoe put --mutable --mutable-type=mdmf, the peak RSS of the gateway (which was also a storage server in this test) was over 1300 MiB. There is also a huge memory leak of more than 700 MiB after the upload has finished.

I originally thought that the memory usage was larger when using the web-API than when updating the same file using SFTP, but apparently that was wrong (I may have been misled by at first doing the SFTP experiment without restarting the nodes).

Change History (8)

comment:1 Changed at 2011-09-02T15:54:16Z by davidsarah

  • Keywords performance added
  • Owner set to davidsarah
  • Status changed from new to assigned

comment:2 follow-up: Changed at 2011-09-02T16:31:42Z by warner

I can imagine two problems here.. which are you thinking of?

  • SFTP only uses SDMF so far (I think), so maybe MDMF uploads use more memory than SDMF, regardless of how the data gets to the gateway
  • the webapi path holds temporary data in different ways than SFTP does (in which case we'd be comparing SFTP-to-SDMF against webapi-to-SDMF)

comment:3 in reply to: ↑ 2 Changed at 2011-09-02T17:24:10Z by davidsarah

Replying to warner:

I can imagine two problems here.. which are you thinking of?

  • SFTP only uses SDMF so far (I think), so maybe MDMF uploads use more memory than SDMF, regardless of how the data gets to the gateway

SFTP will update existing mutable files that are either SDMF or MDMF. In this case we're using SFTP to update an MDMF file as a comparison for the memory that would be used if streaming were supported.

  • the webapi path holds temporary data in different ways than SFTP does (in which case we'd be comparing SFTP-to-SDMF against webapi-to-SDMF)

No, I'm comparing SFTP-to-MDMF against webapi-to-MDMF. We expect the memory usage for SDMF to be bad because that would use a whole-file segment, and there would be more than one segment-sized buffer in memory. For webapi-to-MDMF, on the other hand, we should be able to have only one file-sized buffer in memory even without supporting streaming, and so the memory usage should only be worse than for SFTP-to-MDMF by approximately the file size.

comment:4 Changed at 2011-09-02T18:16:59Z by davidsarah

I started an introducer, 4 storage servers and a gateway. This time the gateway had storage disabled. The encoding parameters of the gateway were k=3, happy=1, N=10. Initially the memory usage as measured by ps -O rss,vsize -C tahoe (command paths snipped for readability) was:

  PID   RSS    VSZ S TTY          TIME COMMAND
16979 39900 163864 S ?        00:00:01 [...]/tahoe start ../grid/introducer
16989 35788 119252 S ?        00:00:00 [...]/tahoe start ../grid/server1
23864 35752 119028 S ?        00:00:00 [...]/tahoe start ../grid/server2
23898 35604 119432 S ?        00:00:00 [...]/tahoe start ../grid/server3
23919 35952 119576 S ?        00:00:00 [...]/tahoe start ../grid/server4
24326 43768 175908 S ?        00:00:00 [...]/tahoe start

I ran bin/tahoe put --mutable --mutable-type=mdmf zeros, where zeros is a file containing 200000000 zero bytes (190.7 MiB). The memory usage of the gateway initially climbed to 1384.5 MiB RSS:

  PID   RSS    VSZ S TTY          TIME COMMAND
16979 39896 163864 S ?        00:00:01 [...]/tahoe start ../grid/introducer
16989 36268 119700 S ?        00:00:00 [...]/tahoe start ../grid/server1
23864 36276 119720 S ?        00:00:00 [...]/tahoe start ../grid/server2
23898 36236 119916 S ?        00:00:00 [...]/tahoe start ../grid/server3
23919 36108 119728 S ?        00:00:00 [...]/tahoe start ../grid/server4
24326 1417760 1549184 R ?     00:00:14 [...]/tahoe start
26433  5064  28488 S pts/3    00:00:00 /usr/bin/python bin/tahoe put --mutable --mutable-type=mdmf zeros
26434 30280 100568 S pts/3    00:00:01 [...]/tahoe put --mutable --mutable-type=mdmf zeros

and then the memory usage of the storage servers climbed uniformly to about 117 MiB RSS each:

  PID   RSS    VSZ S TTY          TIME COMMAND
16979 39688 163864 S ?        00:00:01 [...]/tahoe start ../grid/introducer
16989 120040 203588 D ?       00:00:03 [...]/tahoe start ../grid/server1
23864 119952 203512 D ?       00:00:03 [...]/tahoe start ../grid/server2
23898 119924 203804 R ?       00:00:03 [...]/tahoe start ../grid/server3
23919 119796 203524 D ?       00:00:02 [...]/tahoe start ../grid/server4
24326 1417252 1549184 S ?     00:00:36 [...]/tahoe start
26433  5016  28488 S pts/3    00:00:00 /usr/bin/python bin/tahoe put --mutable --mutable-type=mdmf zeros
26434 30196 100568 S pts/3    00:00:01 [...]/tahoe put --mutable --mutable-type=mdmf zeros

and then more irregularly to a different amount for each server at the end of the command, while the gateway usage dropped to about 746 MiB RSS:

  PID   RSS    VSZ S TTY          TIME COMMAND
16979 38984 163864 S ?        00:00:01 [...]/tahoe start ../grid/introducer
16989 127284 211508 S ?       00:00:06 [...]/tahoe start ../grid/server1
23864 165436 249888 S ?       00:00:05 [...]/tahoe start ../grid/server2
23898 204000 288408 S ?       00:00:09 [...]/tahoe start ../grid/server3
23919 203812 288128 S ?       00:00:09 [...]/tahoe start ../grid/server4
24326 763624 896564 S ?       00:01:10 [...]/tahoe start

There seems to be quite a severe memory leak, since these figures hadn't decreased 20 minutes later.

comment:5 Changed at 2011-09-02T18:27:50Z by davidsarah

I restarted all the nodes, and repeated the experiment using bin/tahoe put --mutable --mutable-type=mdmf zeros <URI from previous run>, i.e. an update rather than an initial upload. The results were similar except that the peak RSS of the gateway process was 1322.5 MiB, and the final usages were:

  PID   RSS    VSZ S TTY          TIME COMMAND
28617 39340 163824 S ?        00:00:00 [...]/tahoe start ../grid/introducer
28627 202768 286752 S ?       00:00:05 [...]/tahoe start ../grid/server1
28637 204752 288772 S ?       00:00:05 [...]/tahoe start ../grid/server2
28647 289676 373704 S ?       00:00:07 [...]/tahoe start ../grid/server3
28657 204468 288544 S ?       00:00:07 [...]/tahoe start ../grid/server4
28667 700936 829076 S ?       00:01:05 [...]/tahoe start

(i.e. 684.5 MiB RSS for the gateway). Again these hadn't decreased several minutes later.

comment:6 Changed at 2011-09-02T18:46:10Z by davidsarah

I restarted all the nodes again, and logged in using sftp -P 8022 127.0.0.1. The memory usage at that point was:

  PID   RSS    VSZ S TTY          TIME COMMAND
29546 39984 163876 S ?        00:00:00 [...]/tahoe start ../grid/introducer
29566 35408 118816 S ?        00:00:00 [...]/tahoe start ../grid/server1
29593 35736 119120 S ?        00:00:00 [...]/tahoe start ../grid/server2
29604 35552 119144 S ?        00:00:00 [...]/tahoe start ../grid/server3
29614 35388 119048 S ?        00:00:00 [...]/tahoe start ../grid/server4
29624 44040 173988 S ?        00:00:00 [...]/tahoe start

I issued the SFTP client command put zeros /uri/<URI from first run>, i.e. updating the same MDMF file.

The results were almost identical to the first experiment (except that the gateway memory usage increase only started after the file had been completely received over SFTP). The peak RSS of the gateway was 1386 MiB, and the final usages were:

  PID   RSS    VSZ S TTY          TIME COMMAND
29546 38480 163876 S ?        00:00:00 [...]/tahoe start ../grid/introducer
29566 180072 266984 S ?       00:00:05 [...]/tahoe start ../grid/server1
29593 134600 221044 S ?       00:00:06 [...]/tahoe start ../grid/server2
29604 203136 288520 S ?       00:00:08 [...]/tahoe start ../grid/server3
29614 286520 373392 S ?       00:00:08 [...]/tahoe start ../grid/server4
29624 763504 896112 S ?       00:01:42 [...]/tahoe start

(i.e. 745.6 MiB RSS for the gateway). These also hadn't decreased several minutes later, or on closing the SFTP connection.

This doesn't support my contention in comment:3 or the original description, that the web-API usage is higher.

Last edited at 2011-09-02T18:54:13Z by davidsarah (previous) (diff)

comment:7 Changed at 2011-09-02T18:50:57Z by davidsarah

  • Description modified (diff)
  • Summary changed from MDMF upload via web-API uses much more memory in the gateway process than updating the same file via SFTP to MDMF upload via web-API uses much more memory in the gateway process than expected

comment:8 Changed at 2011-09-02T19:07:53Z by davidsarah

  • Description modified (diff)
Note: See TracTickets for help on using tickets.