• Re: [gentoo-user] Limiting amount of memory a program can use.

    From Michael@21:1/5 to All on Sun Aug 28 14:03:00 2022
    On Sunday, 28 August 2022 13:56:09 BST Peter Humphrey wrote:
    On Sunday, 28 August 2022 13:24:46 BST Dale wrote:
    Is this something I do on the command line or a setting is some file somewhere? I don't even know where to start on this. By the way, I'm maxed out at 32GBs of memory for this mobo. So adding memory isn't a option. Is there even a mobo that has a 64GB option??? :/

    This may not help, but it may set you on the right track: man ulimit.

    :)

    I'm not sure how you can set a limit for a single application and any of its child processes with ulimit. However, Control Groups (cgroups) can do this easily as long as it has been included in the kernel:

    https://wiki.gentoo.org/wiki/OpenRC/CGroups

    Also, from what I recall at least some torrent applications can limit the amount of uploading connections and/or throughput - but I haven't used any for years now.
    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEXqhvaVh2ERicA8Ceseqq9sKVZxkFAmMLZ4QACgkQseqq9sKV ZxmbZw//TNmcu+9MKDY49dZ4iLu7UYsBqS/99xZ0Sl7tLmwkjhTf5l9Irk086M3Y hM2283H6LnZSWK1PisJzRiTvmIvEUlafa6SrK5nw+tqZPyaSPwpLfmFnqauD+b9P fYpkjXj538aJBZNENKEU3Ljlke2ihaPmFHzB6XTrc1eJQt/pPyk2tY+c4wAGWo2V j7NeExU3gykmgel3gxyB7F2pgrjqsyW4dbEyGGFslGmTCBD4Q+qKhF5sViCW3BqY U9oC04fCW62aYRh0Vmhxzhe2P7YxX9gvQ44sAm+yJ7P9gOLnWY3MTxGFZqViICC4 QnM2+Q/Sgu6ekC4czOhi7v/v45dnxKolixYZqtNwman1pAU7w1CF0vw0WYF+WzDD +kmuXHaS82nI1Gwaqion2xYg9XudVLs3K/F7D21zOf43zvi0mEtJTqlcht7yUAfU iI1qD7ONLrKlak1l4H10Fj6jq1UhASWr2+XIfowwfTaQEQkOOJyREZgUkDK7zp9s 6v3GWqcfCRG7moAZxwTazTT48o8CiVG/ChlFWBFlDCCBUSXTpMNl/25xKCP0LuIs kiVOw2xIAVws5XeP+7roYwK+JzqYk3av8p43TGOv7C9+E+xmFg1TacYa+Ln3XBUb zwwru7HaviucniBislmkNc4vrcWTjD79SRupjBQT0WWtZgWgfI0=
    =CeJo
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dale@21:1/5 to All on Sun Aug 28 14:30:01 2022
    Howdy,

    As most know, I got a much faster internet and I use torrent software,
    quite a lot.  I was using Ktorrent and it was OK but it was slow.  I
    started using Qbittorrent and like it better in a way but it has its own
    speed issues and both affect my desktop response.  I did some googling
    and used top to figure out that they are using a LOT of memory for
    cache.  At times, it uses well over half my memory just for cache.  It
    also gets to a point where it is using swap even tho I have swappiness
    set to 1, basically use swap only to prevent a crash from out of memory problems.  We all know how slow swap use can make things.  As it is, I reduced the number of active files which is not something I want to do. 
    If I receive, I like to send as well.  After all, someone sent to me as well.  What I would like to do is limit the amount of memory torrent
    software can use.  I don't know exactly how to do that tho.  It's not something I've ever done. 

    Is this something I do on the command line or a setting is some file somewhere?  I don't even know where to start on this.  By the way, I'm
    maxed out at 32GBs of memory for this mobo.  So adding memory isn't a option.  Is there even a mobo that has a 64GB option??? :/ 

    Dale

    :-)  :-) 

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Humphrey@21:1/5 to All on Sun Aug 28 15:00:01 2022
    On Sunday, 28 August 2022 13:24:46 BST Dale wrote:

    Is this something I do on the command line or a setting is some file somewhere? I don't even know where to start on this. By the way, I'm
    maxed out at 32GBs of memory for this mobo. So adding memory isn't a
    option. Is there even a mobo that has a 64GB option??? :/

    This may not help, but it may set you on the right track: man ulimit.

    :)

    --
    Regards,
    Peter.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael@21:1/5 to All on Sun Aug 28 14:10:08 2022
    On Sunday, 28 August 2022 14:03:00 BST you wrote:
    On Sunday, 28 August 2022 13:56:09 BST Peter Humphrey wrote:
    On Sunday, 28 August 2022 13:24:46 BST Dale wrote:
    Is this something I do on the command line or a setting is some file somewhere? I don't even know where to start on this. By the way, I'm maxed out at 32GBs of memory for this mobo. So adding memory isn't a option. Is there even a mobo that has a 64GB option??? :/

    This may not help, but it may set you on the right track: man ulimit.

    :)

    I'm not sure how you can set a limit for a single application and any of its child processes with ulimit. However, Control Groups (cgroups) can do this easily as long as it has been included in the kernel:

    https://wiki.gentoo.org/wiki/OpenRC/CGroups

    Also, from what I recall at least some torrent applications can limit the amount of uploading connections and/or throughput - but I haven't used any for years now.

    There is also prlimit which may be more appropriate for a single command? -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEXqhvaVh2ERicA8Ceseqq9sKVZxkFAmMLaTAACgkQseqq9sKV ZxmfOBAAzwHOxif4KexMSPhVCb7dKeAfhZSaE7ICKz/wlb6ojCnQ5aODM80kjS5T H58bVuSlfRuS6suscJNiSNElxDwF5RmOsCCvRg4SDMrf+d61CmVBQphKOF0onGLd SRKlWNsfRghtxOUH36Vtw85itpHn4iZ00cSR7Sp76PiF8hUrCEtr1eCiFOilRSPC RWk/5Oh7TefgiYsAkom4PkEp6lMznto/iEBV4W0s8GrsDHR8A3ek0pOLeeih4t1s K4gklzm2GzhHN2rw/+Mqa8Y4IQUVUzWoIGcTvMle+DxlW4RZ+lfodairp4tQnwZR 3+q2S9fYRHKe9LiXTlbvIX8JTQfNZtDilaA0gtJ8lUufzMNws9nNsVw2f1maZUFD N9IL3u/wjOB54burKfpaztrHIhh19U80PdQ6rOK0bSgQ2dvSEyztrJHjw7RjCv0O xFdMDiF4P2biCkeZlFh19QtaThkmkYnVthE+RnTpTwdqXn0l4CcS3DWtBL/h4XbA Rz5XdBtIsoaKbwaAMGaSBNXX4gCMMXphfZpQN6MifszX9G8uYPd6FuFrTaGlBQaK NU9loRc1f2gdJwUX0qn8kxSMxADhf90+JWz1BI3Gh6C9iAIwBKTyOYdxzavofrAo HFuohn2Q4AiYI3ooSc0okRLRSvqCQhNFpFJV6Sg/MRV88Tsu20U=
    =yy8J
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Knecht@21:1/5 to rdalek1967@gmail.com on Sun Aug 28 16:30:02 2022
    On Sun, Aug 28, 2022 at 5:25 AM Dale <rdalek1967@gmail.com> wrote:
    <SNIP> Is there even a mobo that has a 64GB option??? :/

    Dale

    :-) :-)

    My ROG Strix 570 MB handles up to 128GB. The board and that much memory is pretty expensive though.

    As to your question I suspect sticking the app in a VM would more
    completely limit memory usage.

    HTH,
    Mark

    <div dir="ltr"><br><br>On Sun, Aug 28, 2022 at 5:25 AM Dale &lt;<a href="mailto:rdalek1967@gmail.com">rdalek1967@gmail.com</a>&gt; wrote:<br>&lt;SNIP&gt; Is there even a mobo that has a 64GB option??? :/ <br>&gt;<br>&gt; Dale<br>&gt;<br>&gt; :-)  :-) <
    <br></div><div>My ROG Strix 570 MB handles up to 128GB. The board and that much memory is pretty expensive though.</div><div><br></div><div>As to your question I suspect sticking the app in a VM would more completely limit memory usage.</div><div><br>
    </div><div>HTH,</div><div>Mark</div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich Freeman@21:1/5 to rdalek1967@gmail.com on Sun Aug 28 16:30:01 2022
    On Sun, Aug 28, 2022 at 8:24 AM Dale <rdalek1967@gmail.com> wrote:

    What I would like to do is limit the amount of memory torrent
    software can use.

    While ulimit/cgroups/etc will definitely do the job, they're probably
    not the solution you want. Those will cause memory allocation to
    fail, and I'm guessing at that point your torrent software will just
    die.

    I'd see if you can do something within the settings of the program to
    limit its memory use, and then use a resource limit at the OS level as
    a failsafe, so that a memory leak doesn't eat up all your memory.

    Otherwise your next email will be asking how to automatically restart
    a dead service. Systemd has support for that built-in, and there are
    also options for non-systemd, but you're going to be constantly having
    restarts and it might not even run for much time at all depending on
    how bad the problem is. It is always best to tame memory use within
    an application.

    Something I wish linux supported was discardable memory, for
    caches/etc. A program should be able to allocate memory while passing
    a hint to the kernel saying that the memory is discardable. If the
    kernel is under memory pressure it can then just deallocate the memory
    and then have some way to notify the process that the memory no longer
    is allocated. That might optionally support giving warning first, or
    it might be some kind of new trappable exception for segfaults to
    discarded memory. (Since access to memory doesn't involve system
    calls it might be hard to have more graceful error handling. I guess
    an option would be to first tell the kernel to lock the memory before
    accessing it, then release the lock, so that the memory isn't
    discarded after checking that it is safe.)

    --
    Rich

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wols Lists@21:1/5 to Rich Freeman on Sun Aug 28 17:40:01 2022
    On 28/08/2022 15:21, Rich Freeman wrote:
    Something I wish linux supported was discardable memory, for
    caches/etc. A program should be able to allocate memory while passing
    a hint to the kernel saying that the memory is discardable.

    Linux DOES have that ...

    I'm not sure how to use it, but you can pass a flag to open(), which
    says "do not cache this file". The obvious use case is something like
    cp, but there's plenty of others. Or there are applications which cache
    stuff in the app, so don't want to waste OS cache as well - databases
    are a prime example.

    Apparently not only does memory use crash when this is actively used,
    but because the OS does not have to manage cache, speed is actually
    noticeably impacted. Given the obsession kernel devs have with not
    wasting memory and time, this is likely to be actively maintained and supported. We just need to find out how to access this from user space.

    Cheers,
    Wol

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ralfconn@21:1/5 to Dale on Sun Aug 28 18:50:02 2022
    On 8/28/22 14:24, Dale wrote:
    Howdy,

    As most know, I got a much faster internet and I use torrent software,
    quite a lot.  I was using Ktorrent and it was OK but it was slow.  I started using Qbittorrent and like it better in a way but it has its own speed issues and both affect my desktop response.  I did some googling
    and used top to figure out that they are using a LOT of memory for
    cache.  At times, it uses well over half my memory just for cache.  It
    also gets to a point where it is using swap even tho I have swappiness
    set to 1, basically use swap only to prevent a crash from out of memory problems.  We all know how slow swap use can make things.  As it is, I reduced the number of active files which is not something I want to do.
    If I receive, I like to send as well.  After all, someone sent to me as well.  What I would like to do is limit the amount of memory torrent software can use.  I don't know exactly how to do that tho.  It's not something I've ever done.

    Is this something I do on the command line or a setting is some file somewhere?  I don't even know where to start on this.  By the way, I'm maxed out at 32GBs of memory for this mobo.  So adding memory isn't a option.  Is there even a mobo that has a 64GB option??? :/

    Not really an answer to your question but here I never had speed/responsiveness/memory issues with transmission (Xfce, 16Gb RAM,
    50Mbit/s network bandwidth ):

    [I] net-p2p/transmission

         Available versions:  3.00-r1^t (~)3.00-r4^t **9999*l^t
    {appindicator cli gtk lightweight mbedtls nls qt5 systemd test web}
         Installed versions:  3.00-r4^t(01:14:38 PM 05/29/2022)(cli nls -appindicator -gtk -lightweight -mbedtls -qt5 -systemd -test)
         Homepage:            https://transmissionbt.com/
         Description:         A fast, easy, and free BitTorrent client

    I use it without GUI (-gtk -qt5) because I find the web interface just
    fine. Also, being server-based it runs regardless of who's logged into
    the PC, which is a plus here.

    raffaele

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich Freeman@21:1/5 to antlists@youngman.org.uk on Sun Aug 28 23:20:01 2022
    On Sun, Aug 28, 2022 at 11:32 AM Wols Lists <antlists@youngman.org.uk> wrote:

    On 28/08/2022 15:21, Rich Freeman wrote:
    Something I wish linux supported was discardable memory, for
    caches/etc. A program should be able to allocate memory while passing
    a hint to the kernel saying that the memory is discardable.

    Linux DOES have that ...

    I'm not sure how to use it, but you can pass a flag to open(), which
    says "do not cache this file".

    That isn't what I was proposing. That has been around for a while.
    However, it only impacts caching/buffering of open files, which is
    kernel memory, and not memory held by a process itself.

    You wouldn't want to limit kernel file caching of a torrent file,
    since those files are pretty ideal candidates for caching (since the
    client is likely to send data not long after receiving it). There
    isn't really any benefit to this either in this case as the kernel
    already automatically drops file cache memory as needed under memory
    pressure.

    I was referring to application caching, which is internal storage used
    by an application that may or may not have anything to do with open
    files. A browser cache is a good example of something like this
    (though that extends to disk caching often and those files would also
    get cached by the kernel). The kernel can't simply drop this memory
    when it needs memory since there is no way for it to tell which memory
    an application owns is used for this purpose, and no way currently to
    handle the resulting segfaults when the application goes to read that
    memory. Reading memory is a CPU instruction, not a system call, so it
    would trigger an exception at the CPU level which must be handled.

    I'm sure something could be engineered but it is more complex and I'm
    guessing nobody has seen the need for it yet. Ideally you'd also have
    ways for the OS to hint how much memory applications ought to consume
    in this way. After all, you might have two applications running at
    the same time, which both want to use lots of extra RAM for caching if
    it is available, but neither has any way of knowing that this
    situation exists and it is undesirable if all the memory goes to the
    first application that asks, and also undesirable if after everything
    is done grabbing memory if there is a bunch of it sitting around doing
    nothing.

    TL;DR: cache is not necessarily the same as kernel file cache.

    --
    Rich

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dale@21:1/5 to ralfconn on Mon Aug 29 09:30:01 2022
    ralfconn wrote:
    On 8/28/22 14:24, Dale wrote:
    Howdy,

    As most know, I got a much faster internet and I use torrent software,
    quite a lot.  I was using Ktorrent and it was OK but it was slow.  I
    started using Qbittorrent and like it better in a way but it has its own
    speed issues and both affect my desktop response.  I did some googling
    and used top to figure out that they are using a LOT of memory for
    cache.  At times, it uses well over half my memory just for cache.  It
    also gets to a point where it is using swap even tho I have swappiness
    set to 1, basically use swap only to prevent a crash from out of memory
    problems.  We all know how slow swap use can make things.  As it is, I
    reduced the number of active files which is not something I want to do.
    If I receive, I like to send as well.  After all, someone sent to me as
    well.  What I would like to do is limit the amount of memory torrent
    software can use.  I don't know exactly how to do that tho.  It's not
    something I've ever done.

    Is this something I do on the command line or a setting is some file
    somewhere?  I don't even know where to start on this.  By the way, I'm
    maxed out at 32GBs of memory for this mobo.  So adding memory isn't a
    option.  Is there even a mobo that has a 64GB option??? :/

    Not really an answer to your question but here I never had speed/responsiveness/memory issues with transmission (Xfce, 16Gb RAM, 50Mbit/s network bandwidth ):

    [I] net-p2p/transmission

         Available versions:  3.00-r1^t (~)3.00-r4^t **9999*l^t {appindicator cli gtk lightweight mbedtls nls qt5 systemd test web}
         Installed versions:  3.00-r4^t(01:14:38 PM 05/29/2022)(cli nls -appindicator -gtk -lightweight -mbedtls -qt5 -systemd -test)
         Homepage:            https://transmissionbt.com/
         Description:         A fast, easy, and free BitTorrent client

    I use it without GUI (-gtk -qt5) because I find the web interface just
    fine. Also, being server-based it runs regardless of who's logged into
    the PC, which is a plus here.

    raffaele


    I may look into that.  Just to see if it is even better than Ktorrent
    and Qbittorrent.  Never know.  I may like it like Mikey.  lol  It's a
    old TV commercial. 

    I'm not sure what happened but it started acting better.  One, I did
    remove a lot of items that were just sitting there.  Then I removed some
    that had a high share ratio, I did a lot of sharing.  There was also a
    update to QBT but at first it didn't help any.  It was after a few
    restarts that it seemed to improve.  I did notice that at one point it
    was uploading around 60 or 70MB/sec and desktop response slowed some but
    not as bad as before.  I guess I need to limit what it uploads a bit.  I
    know how to do that. 

    So, I think the update improved things but took a few restarts to kick
    in or something.  Removing some unused files helped too.  I wonder if I
    could use torrent on a Raspberry Pi?  :-)  lol 

    By the way, I notice this in df and mount:


    root@fireball / # df -h | grep group cgroup_root                 10M     0   10M   0% /sys/fs/cgroup
    root@fireball / # mount | grep group
    cgroup_root on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755)
    openrc on /sys/fs/cgroup/openrc type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/lib/rc/sh/cgroup-release-agent.sh,name=openrc)
    none on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
    gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
    portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
    root@fireball / #

    I guess cgroups is enabled but I never touched any of it.  Only read a
    few threads on here about it. 

    Thanks to all.

    Dale

    :-)  :-) 

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Matt Connell@21:1/5 to All on Mon Aug 29 18:10:01 2022
    How many torrents are you seeding, for a point of comparison?

    I use deluge (headless) on my home server, seeding anywhere from 500-
    1000 individual torrents, representing ~5TB of total data, and the
    process is cruising along at just over 1GB of memory used.

    Maybe qbittorrent just doesn't scale well? I feel like I'm on the exceedingly-high end of the spectrum with usage of a torrent program,
    but I don't know what everyone else is doing.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mad.scientist.at.large@tutanota.com@21:1/5 to All on Mon Aug 29 23:10:02 2022
    --"Fascism begins the moment a ruling class, fearing the people may use their political democracy to gain economic democracy, begins to destroy political democracy in order to retain its power of exploitation and special privilege." Tommy Douglas




    Aug 29, 2022, 10:07 by matt@connell.tech:

    How many torrents are you seeding, for a point of comparison?

    I use deluge (headless) on my home server, seeding anywhere from 500-
    1000 individual torrents, representing ~5TB of total data, and the
    process is cruising along at just over 1GB of memory used.

    Maybe qbittorrent just doesn't scale well? I feel like I'm on the exceedingly-high end of the spectrum with usage of a torrent program,
    but I don't know what everyone else is doing.

    Faster hard drives/striped raid array would help.  Also check out the "Advanced" section of the preferences in Qbit.  You can control memory use somewhat from there and definitely turn off multiple connections from the same host.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dale@21:1/5 to Matt Connell on Tue Aug 30 03:00:01 2022
    Matt Connell wrote:
    How many torrents are you seeding, for a point of comparison?

    I use deluge (headless) on my home server, seeding anywhere from 500-
    1000 individual torrents, representing ~5TB of total data, and the
    process is cruising along at just over 1GB of memory used.

    Maybe qbittorrent just doesn't scale well? I feel like I'm on the exceedingly-high end of the spectrum with usage of a torrent program,
    but I don't know what everyone else is doing.




    At one point, I had about 400 or so total, some downloading, some
    finished and uploading while some were doing both.  I may have to switch
    to something else before it is over.  I may even put it on a different
    machine or use something else to put my videos on the TV, HTPC thingy.
    Since I've found things that were hard to find elsewhere, I want to
    return the favor.  So, I'd really like to hold onto those that are hard
    to find. 

    After I removed some of the inactive ones, it is a lot better.  I also
    limited the upload speed which helped a lot.  According to atop, when uploading at higher speeds, the reads were really putting a load on that
    set of drives.  Does deluge have a GUI option?  Of course, if I put it
    on another machine, I may go headless for it.  That's one reason I'm
    asking.  Options.

    And as soon as I think it is better, it slows down again and I find this
    from top:


    27672 dale 20 0 410.7g 4.3g 4.1g S 2.2 13.6 158:26.37 /usr/bin/qbittorrent


    It's not nearly as bad as it was when I started this thread but still,
    that's a lot of memory.

    Dale

    :-)  :-) 

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Matt Connell@21:1/5 to Dale on Tue Aug 30 16:00:01 2022
    On Mon, 2022-08-29 at 16:11 -0500, Dale wrote:
    Does deluge have a GUI option?  Of course, if I put it
    on another machine, I may go headless for it.  That's one reason I'm asking.  Options.

    Yes, deluge has a GUI by default. I just build it with USE="-gtk -
    libnotify -sound webinterface" and then access it by
    http://<serverip>:port from a desktop PC instead.

    If you want more details about my setup I'm happy to provide.

    Also, for the record, all of my torrent data is on a *USB external hard
    disk* which is about the slowest possible workable solution, but it
    still performs adequately for my needs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)