Are segments so bad?

By: Jukka Larja (roskakori2006.delete@this.gmail.com),
Room: Moderated Discussions
Brendan (btrotter.delete@this.gmail.com) on January 18, 2020 11:40 am wrote:
> Jukka Larja (roskakori2006.delete@this.gmail.com) on January 17, 2020 9:08 pm wrote:
> > Brendan (btrotter.delete@this.gmail.com) on January 17, 2020 12:52 pm wrote:
> >
> > > The difference is when you find out that you need to deal with a low memory problem - in a well defined
> > > place (as soon as you try to allocate the memory) where it's easy to control the circumstances, or "at
> > > any time, almost anywhere" where you have to worry about the least convenient circumstances.
> >
> > So in your opinion, when ever one writes "new" or "malloc", there should be (serious) handler
> > in case of OOM? Able to release some random caches and so on, if at all applicable to that
> > particular software? And you consider that something everyone should spend time on?
>
> In my opinion; a software developer should be able to do whatever they think is sane for their software

Ok, I agree with this. What I obviously don't agree with is "sane" for most software.

> (which could include dropping cached data, and/or waiting until another thread finishes and
> releases resources,
> and/or refusing to accept additional work to ensure already accepted work succeeds,

I don't really see how one is supposed to do these things without trying to allocate any new memory, except in trivial toy examples.

> and/or reporting failure
> in a way that is consistent with the way all other problems are reported, and/or anything else); and a
> software developer should not be prevented from doing whatever they think is sane because they're forced
> to accept something that is almost never sane (either OOM killer, or SIGBUS that is unusable for most
> cases, or constant monitoring that can't solve the problem due to race conditions).

How exactly is getting an OOM on memory allocation so much better than getting it at some other random time via signal? In typical code, most allocations probably aren't done by applications own code, but some library. For example, put some std::string or std::vector to stack and they will allocate from heap too. If there's a system wide OOM going on, how can you even expect to be able to write a log message?

> Yes; but even for games, "what makes sense for the game" can depend on the game. For example, maybe for
> one game it makes sense to do an auto-save before changing to a different level/zone, then load everything
> and pre-allocate everything for the next level/zone (while managing allocation failures), then not have
> a reason to care while the player remains in that level/zone because you know everything was already allocated
> successfully; and maybe for a different game that approach can't make sense because there are no levels/zones
> (or there's multiple players or ...) and something very different is far more suitable.

Yeah, sure. If things happen to be just right, then it makes sense to do X. The game will need extra buffers to load everything the level needs from disk. They will be needed right until everything is loaded, at which point the memory consumption will be the highest (add some random variation due to multithreading and the fact that the player may decide to put the console to sleep in the middle of this).

You are also completely ignoring that memory fragmentation gets really bad really fast, if you are constantly running near the limit. If your normal mode of operation is doing something in response to allocation failures, you're screwed anyway. All that crazy amount of error handling for nothing (note that this is no longer about system wide OOM, but strictly what's happening inside a game on a console).

-JLarja
< Previous Post in ThreadNext Post in Thread >
Thread (397 posts)
TopicPosted ByPosted
Nuances related to Spinlock implementation and the Linux SchedulerBeastian
  Nuances related to Spinlock implementation and the Linux SchedulerMontaray Jack
    Nuances related to Spinlock implementation and the Linux SchedulerMontaray Jack
  No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
    No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Beastian
    No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Malte Skarupke
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)dmcq
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)smeuletz
          Do not blame others for your unfinished jobsmeuletz
            Where did all the experts come from? Did Linus get linked? (NT)anon
              PhoronixGabriele Svelto
                PhoronixSalvatore De Dominicis
            Do not blame anyone. Please give polite, constructive criticismChester
              Do not blame anyone. Please give polite, constructive criticismsmeuletz
                Do not blame anyone. Please give polite, constructive criticismChester
                  Do not blame anyone. Please give polite, constructive criticismsmeuletz
                    Do not blame anyone. Please give polite, constructive criticismLinus Torvalds
                      Do not blame anyone. Please give polite, constructive criticismGionatan Danti
                        Do not blame anyone. Please give polite, constructive criticismLinus Torvalds
                          Do not blame anyone. Please give polite, constructive criticismGionatan Danti
                          Do not blame anyone. Please give polite, constructive criticismJohn Scott
                          Do not blame anyone. Please give polite, constructive criticismsupernovas
                            Do not blame anyone. Please give polite, constructive criticismLinus Torvalds
                          Do not blame anyone. Please give polite, constructive criticismGDan
                            OracleAnon3
                      Do not blame anyone. Please give polite, constructive criticismsmeuletz
                        Do not blame anyone. Please give polite, constructive criticismSimon Farnsworth
                        Do not blame anyone. Please give polite, constructive criticismEtienne
                          Do not blame anyone. Please give polite, constructive criticismsmeuletz
                            Do not blame anyone. Please give polite, constructive criticismMichael S
                      Not deprecating irrelevant API: sched_yield() on quantum computers?smeuletz
                      Do not blame anyone. Please give polite, constructive criticismmagicalgoat
                        Do not blame anyone. Please give polite, constructive criticismLinus Torvalds
                          Do not blame anyone. Please give polite, constructive criticismAnon3
                  Do not blame anyone. Please give polite, constructive criticismrwessel
                Do not blame anyone. Please give polite, constructive criticismLinus Torvalds
                  Do not blame anyone. Please give polite, constructive criticismGabriele Svelto
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Howard Chu
          No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)president ltd
    No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Jörn Engel
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Emil Briggs
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Jörn Engel
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
          No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Jörn Engel
            No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Linus Torvalds
              FUTEX_LOCK_PI performanceJörn Engel
                FUTEX_LOCK_PI performanceLinus Torvalds
                  FUTEX_LOCK_PI performanceJörn Engel
                    FUTEX_LOCK_PI performanceRichardC
                      FUTEX_LOCK_PI performanceLinus Torvalds
                  FUTEX_LOCK_PI performanceGabriele Svelto
                    FUTEX_LOCK_PI performancexilun
                    FUTEX_LOCK_PI performanceKonrad Schwarz
                      FUTEX_LOCK_PI performanceGabriele Svelto
                      FUTEX_LOCK_PI performanceSimon Farnsworth
                      FUTEX_LOCK_PI performancerwessel
    No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)rainstar
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Charles Ellis
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Richard
          It's hard to separateMichael S
            It's hard to separaterainstared
              It's hard to separateDavid Kanter
                It's hard to separateAnon
                  It's hard to separatenone
                    It's hard to separateAnon
                      It's hard to separatenone
                        It's hard to separategallier2
                          It's hard to separateAnon
                            It's hard to separateAdrian
                              It's hard to separategallier2
                                It's hard to separateAdrian
                            It's hard to separategallier2
                        It's hard to separateAdrian
                        It's hard to separateAnon
                          It's hard to separategallier2
                          It's hard to separateDavid Hess
                            It's hard to separateAdrian
                              It's hard to separateDavid Hess
                                It's hard to separateAnon
                                  It's hard to separateAdrian
                                    It's hard to separateBrett
                                      Zilog Z8000Brett
                                        Zilog Z8000David Hess
                                          Zilog Z8000Adrian
                                            Zilog Z8000David Hess
                                              Zilog Z8000Ricardo B
                                                Zilog Z8000Ronald Maas
                                                  Zilog Z8000Ricardo B
                                                    Zilog Z8000Anon
                                                      Zilog Z8000Jose
                                                        Zilog Z8000gallier2
                                                          Zilog Z8000Jose
                                                            Zilog Z8000rwessel
                                                              Zilog Z8000David Hess
                                                                Zilog Z8000Simon Farnsworth
                                                                  Zilog Z8000Michael S
                                                                    Zilog Z8000Simon Farnsworth
                                                                      Zilog Z8000David Hess
                                                                  Zilog Z8000David Hess
                                                                Zilog Z8000rwessel
                                                                  286 16 bit I/OTim McCaffrey
                                                                    286 16 bit I/ODavid Hess
                                                      Zilog Z8000Ricardo B
                                                        Zilog Z8000Anon
                                                          Zilog Z8000David Hess
                                                            Zilog Z8000rwessel
                                                              Zilog Z8000David Hess
                                                          Zilog Z8000someone
                                                            Zilog Z8000Anon
                                                          Zilog Z8000Ricardo B
                                                  Zilog Z8000Simon Farnsworth
                                                    Zilog Z8000Tim McCaffrey
                                                      Zilog Z8000Simon Farnsworth
                                                    Zilog Z8000Ricardo B
                                                      Zilog Z8000Anon
                                                        Zilog Z8000Ricardo B
                                                          Zilog Z8000Anon
                                                            Zilog Z8000Ricardo B
                                                              Zilog Z8000Anon
                                                                Zilog Z8000David Hess
                                                                Zilog Z8000Ricardo B
                                                                  Zilog Z8000Anon
                                                                    Zilog Z8000Ronald Maas
                                                                      Zilog Z8000Anon
                                                                    Zilog Z8000Ricardo B
                                                                      Zilog Z8000Anon
                                                                        Zilog Z8000Ricardo B
                                                                          Zilog Z8000gallier2
                                                                    Zilog Z8000David Hess
                                                            Zilog Z8000David Hess
                                                          Zilog Z8000gallier2
                                                      Zilog Z8000Simon Farnsworth
                                                        IBM PC successEtienne
                                                        Zilog Z8000Ricardo B
                                                          Zilog Z8000Brett
                                                            Zilog Z8000David Hess
                                                          Zilog Z8000David Hess
                                                    Zilog Z8000David Hess
                                            Zilog Z8000Maxwell
                                              Zilog Z8000David Hess
                                                Zilog Z8000Maxwell
                                                  Zilog Z8000Ricardo B
                                                    8086 does NOT have those addressing modesDevin
                                                      8086 does NOT have those addressing modesRicardo B
                                                        8086 does NOT have those addressing modesAnon
                                                          8086 does NOT have those addressing modesgallier2
                                                            8086 does NOT have those addressing modesAnon
                                                              8086 does NOT have those addressing modesRicardo B
                                                          8086 does NOT have those addressing modesMichael S
                                                            Zilog Z8000Ronald Maas
                                                              Zilog Z8000Anon
                                                          8086 does NOT have those addressing modesRicardo B
                                                            8086 does NOT have those addressing modesrwessel
                                                              8086 does NOT have those addressing modesDavid Hess
                                                                8086 does NOT have those addressing modesrwessel
                                                                  8086 does NOT have those addressing modesDavid Hess
                                                          8086 does NOT have those addressing modesDavid Hess
                                            Zilog Z8000rwessel
                                              Zilog Z8000Brett
                                                Zilog Z8000rwessel
                                                  Zilog Z8000Brett
                                                    Zilog Z8000rwessel
                                                      Zilog Z8000Brett
                                                    Zilog Z8000James
                                              Zilog Z8000Adrian
                                                PDP-11Michael S
                                                Zilog Z8000rwessel
                                              Zilog Z8000Ronald Maas
                                            Zilog Z8000Konrad Schwarz
                                              Zilog Z8000Adrian
                                                Zilog Z8000konrad.schwarz
                                                  Zilog Z8000Adrian
                                    It's hard to separateDavid Hess
                                  It's hard to separateDavid Hess
                                It's hard to separateAdrian
                                  It's hard to separateDavid Hess
                                It's hard to separategallier2
                                  It's hard to separatenone
                        It's hard to separaterwessel
                        It's hard to separateDavid Hess
                          It's hard to separaterwessel
                  It's hard to separateAdrian
                    It's hard to separaterwessel
                      It's hard to separateAdrian
                    It's hard to separateDavid Hess
                      It's hard to separatenone
                  Are segments so bad?Paul A. Clayton
                    Yes, they are terrible (NT)Anon
                    Are segments so bad?Adrian
                      Are segments so bad?Etienne
                        Are segments so bad?gallier2
                          Are segments so bad?Adrian
                            Are segments so bad?Adrian
                              Are segments so bad?Etienne
                        Are segments so bad?Adrian
                          Are segments so bad?gallier2
                      Are segments so bad?Anon3
                        Are segments so bad?Adrian
                          Are segments so bad?Brendan
                      Are segments so bad?Anon
                        Are segments so bad?Adrian
                          Are segments so bad?Jukka Larja
                            Are segments so bad?Brendan
                              Are segments so bad?Jukka Larja
                                Are segments so bad?Brendan
                                  Are segments so bad?Jukka Larja
                                  Are segments so bad?anon
                                    Are segments so bad?Brendan
                                      the world sucks worse than you're aware ofMichael S
                                        the world sucks worse than you're aware ofBrendan
                                        the world sucks worse than you're aware ofGabriele Svelto
                                      Are segments so bad?Jukka Larja
                                        Are segments so bad?Brendan
                                          Are segments so bad?Jukka Larja
                                            Are segments so bad?Brendan
                                              Are segments so bad?Anne O. Nymous
                                                Are segments so bad?Brendan
                                                  actor of around 200?Michael S
                                                  Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                    Not overcomitting leads to more OOMs, not lessBrendan
                                                      Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                        Not overcomitting leads to more OOMs, not lessAnon
                                                          Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                            Not overcomitting leads to more OOMs, not lessAnon
                                                              Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                                Not overcomitting leads to more OOMs, not lessAnon
                                                                  Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                        Not overcomitting leads to more OOMs, not lessMichael S
                                                          Not overcomitting leads to more OOMs, not lessGabriele Svelto
                                                            Not overcomitting leads to more OOMs, not lessMichael S
                                                              Not overcomitting leads to more OOMs, not lessJukka Larja
                                                        Not overcomitting leads to more OOMs, not lessJukka Larja
                                                          Thanks for the info (NT)Gabriele Svelto
                                                      Not overcomitting leads to more OOMs, not lessLinus Torvalds
                                                        OOM killer complainsAnon
                                                          OOM killer complainsanon
                                                        Not overcomitting leads to more OOMs, not lessBrendan
                                                          Not overcomitting leads to more OOMs, not lessLinus Torvalds
                                                            Not overcomitting leads to more OOMs, not lessLinus Torvalds
                                                              Not overcomitting leads to more OOMs, not lessDoug S
                                                                Not overcomitting leads to more OOMs, not lessDoug S
                                                Are segments so bad?rwessel
                                              Are segments so bad?Jukka Larja
                                                Are segments so bad?Brendan
                                                  Are segments so bad?Jukka Larja
                                                    Are segments so bad?Brendan
                                                      Are segments so bad?Brett
                                                      Are segments so bad?Jukka Larja
                                                  Are segments so bad?Gabriele Svelto
                                            Specifying cost of dropping pagesPaul A. Clayton
                                              Specifying cost of dropping pagesrwessel
                                                Specifying cost of dropping pagesGabriele Svelto
                                          Are segments so bad?anon
                                            Are segments so bad?Brendan
                                          Are segments so bad?Gabriele Svelto
                                            Are segments so bad?Brendan
                                              Are segments so bad?Gabriele Svelto
                                                Are segments so bad?Anon
                                                  Are segments so bad?Jukka Larja
                                                Are segments so bad?Etienne
                                                  Are segments so bad?Jukka Larja
                                                    Are segments so bad?Gabriele Svelto
                                                      Are segments so bad?Jukka Larja
                                                Are segments so bad?Brendan
                                                  Are segments so bad?Gabriele Svelto
                                                    Are segments so bad?Brendan
                                                      Are segments so bad?Jukka Larja
                                                        Are segments so bad?Brendan
                                                          Are segments so bad?Jukka Larja
                                                            Are segments so bad?Brendan
                                                              Are segments so bad?Jukka Larja
                                                                Are segments so bad?Brendan
                                                                  Are segments so bad?Brett
                                                                    Are segments so bad?Brett
                                                                  Are segments so bad?Gabriele Svelto
                                                                  Are segments so bad?Jukka Larja
                                                                    Are segments so bad?Brendan
                                                                      Are segments so bad?Jukka Larja
                                                                        Are segments so bad?Brendan
                                                                          Are segments so bad?Jukka Larja
                                                                            Are segments so bad?Brendan
                                                                              Are segments so bad?Jukka Larja
                                                      Are segments so bad?rwessel
                                                      Are segments so bad?Gabriele Svelto
                                                        Are segments so bad?Brendan
                                                          Are segments so bad?Gabriele Svelto
                                                            Are segments so bad?Anon
                                                              Are segments so bad?Gabriele Svelto
                                                            Are segments so bad?Brendan
                                                              Are segments so bad?Gabriele Svelto
                                                                Are segments so bad?Michael S
                                                                  Are segments so bad?Gabriele Svelto
                                                                    Are segments so bad?Jukka Larja
                                                                    Are segments so bad?Michael S
                                                                      Are segments so bad?Gabriele Svelto
                                                                Are segments so bad?Brendan
                                                                  Are segments so bad?Michael S
                                                                    Are segments so bad?Brendan
                                                                      Are segments so bad?Simon Farnsworth
                                                                        Are segments so bad?Anon
                                                                          Are segments so bad?Simon Farnsworth
                                                                      Are segments so bad?Michael S
                                                                  Are segments so bad?Gabriele Svelto
                                                                    Are segments so bad?Brendan
                                                                      Are segments so bad?Gabriele Svelto
                                                                        Are segments so bad?Brendan
                                                                          Are segments so bad?Jukka Larja
                                                                            Are segments so bad?Brendan
                                                                              Are segments so bad?Jukka Larja
                                                                                Are segments so bad?Brendan
                                                                                  Are segments so bad?Jukka Larja
                                                                                    Are segments so bad?Brendan
                                                                                      Are segments so bad?Jukka Larja
                                                                                        Are segments so bad?Brendan
                                                                                          Are segments so bad?Jukka Larja
                                                                                            Are segments so bad?Gabriele Svelto
                                                                                              Are segments so bad?Jukka Larja
                                                                                                DDS assets and MipMap chainsMontaray Jack
                                                                                      Are segments so bad?gallier2
                                                                                        Are segments so bad?Jukka Larja
                                                                                  Are segments so bad?Anne O. Nymous
                                                                            Are segments so bad?Anon
                                                                              Are segments so bad?Anne O. Nymous
                                                                                Are segments so bad?Anon
                                                                                  Are segments so bad?Anne O. Nymous
                                                                                    Are segments so bad?Anon
                                                                                      Are segments so bad?Etienne
                                                                              Are segments so bad?Gabriele Svelto
                                                                                Are segments so bad?Michael S
                                                                                Are segments so bad?Jukka Larja
                                                                                  Are segments so bad?Gabriele Svelto
                                                                                    Are segments so bad?Anon
                                                                                      Are segments so bad?Jukka Larja
                                                                                Are segments so bad?Anon
                                                                                  Are segments so bad?Gabriele Svelto
                                                                                    Are segments so bad?Anon
                                                                                      Are segments so bad?Gabriele Svelto
                                                                                        Are segments so bad?Anon
                                                                                          Are segments so bad?Gabriele Svelto
                                                                                            Are segments so bad?Anon
                                                                                              Are segments so bad?Gabriele Svelto
                                                                                                Are segments so bad?Anon3
                                                                                                Are segments so bad?Anon
                                                                                  Are segments so bad?Jukka Larja
                                                          Are segments so bad?Jukka Larja
                                Are segments so bad?Anne O. Nymous
                                  Are segments so bad?Jukka Larja
                            Are segments so bad?rwessel
                          Are segments so bad?Anne O. Nymous
                      Are segments so bad?Ricardo B
                        Are segments so bad?Adrian
                          Are segments so bad?Michael S
                            Are segments so bad?Adrian
                          Are segments so bad?Ricardo B
                            Are segments so bad?Anon3
                            Are segments so bad?Brendan
                      Are segments so bad?Paul A. Clayton
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)rainstared
          No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Foo_
            No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)dmcq
            changes in contextCarlie Coats
      No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)rainstar
        No nuances, just buggy code (was: related to Spinlock implementation and the Linux Scheduler)Montaray Jack
    Suggested reading for the authoranon
      Suggested reading for the authorab
        Looking at the other side (frequency scaling)Chester
          Looking at the other side (frequency scaling)Foo_
          Why spinlocks were usedFoo_
            Why spinlocks were usedJukka Larja
            Why spinlocks were usedSimon Cooke
            Why spinlocks were usedRizzo
          Looking at the other side (frequency scaling)ab
    Cross-platform codeGian-Carlo Pascutto
      Cross-platform codeMichael S
        Cross-platform codeGian-Carlo Pascutto
          Cross-platform codeMichael S
            Cross-platform codeNksingh
              Cross-platform codeMichael S
              SRW lock implementationMichael S
                SRW lock implementationNksingh
                  broken URL in Linux source codeMichael S
                    broken URL in Linux source codeTravis Downs
                      broken URL in Linux source codeMichael S
                        broken URL in Linux source codeTravis Downs
                  SRW lock implementation - url brokenMichael S
                    SRW lock implementation - url brokenTravis Downs
                      SRW lock implementation - url brokengpderetta
                        SRW lock implementation - url brokenTravis Downs
                      SRW lock implementation - url brokenLinus Torvalds
                        SRW lock implementation - url brokenTravis Downs
                          SRW lock implementation - url brokenLinus Torvalds
                    SRW lock implementation - url brokenKonrad Schwarz
                    SRW lock implementation - url brokennksingh
      Cross-platform codeLinus Torvalds