Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. Do you ever daydream about the incredibly wild optimizations a garbage collector could do if it had the direct control over virtual memory layout an operating system does

Do you ever daydream about the incredibly wild optimizations a garbage collector could do if it had the direct control over virtual memory layout an operating system does

Scheduled Pinned Locked Moved Uncategorized
49 Posts 23 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mcc@mastodon.socialM mcc@mastodon.social

    Do you ever daydream about the incredibly wild optimizations a garbage collector could do if it had the direct control over virtual memory layout an operating system does

    glyph@mastodon.socialG This user is from outside of this forum
    glyph@mastodon.socialG This user is from outside of this forum
    glyph@mastodon.social
    wrote last edited by
    #16

    @mcc does daydreaming of a world where garbage collection is the operating system’s job count

    mcc@mastodon.socialM driusan@doomscroller.socialD 2 Replies Last reply
    0
    • mcc@mastodon.socialM mcc@mastodon.social

      @kasperd Like mmmaaaybbbe I could find a mmap mode where I pre-mmap a 32GB buffer but it doesn't actually assign those pages until I stop using them? I guess? 😕

      kasperd@westergaard.socialK This user is from outside of this forum
      kasperd@westergaard.socialK This user is from outside of this forum
      kasperd@westergaard.social
      wrote last edited by
      #17

      You can use MAP_FIXED to get a range on a specific address. The address you specify that way does get rounded down to a multiple of the page size, but other than that it's used as is.

      A zero value for address has a special meaning, so if you absolutely want to map at address 0 you need to ask for address 1 rounded down. Though some kernels won't permit that in the default configuration.

      You can ask for more memory ahead of time. I am pretty sure the kernel only allocates the physical memory on the first write. However things get a little tricky with respect to over-commitment and such. As I understand it, the kernel will refuse the allocation if there is no way it could ever give you all of that memory. But I think the default is that when there is any doubt the kernel will let the allocation go through and kill the process later if it doesn't have memory after all. (I am not saying that's a good default.)

      There is also the possibility of allocating a memory range with no permissions and then use mprotect to make parts of the range read and writable later. In that case it would make sense to me if the kernel only updates the count of committed memory once you make it writable, I don't know if that's actually what happens, but it should be easy to test.

      I have used the approach of using mmap to allocate a range with no read or write permissions and then make a small range in the middle read-write with mprotect. My reason for using it has been to have guard pages around certain buffers as a security measure. It provides an extra layer of protection against buffer overflow vulnerabilities.

      For some advanced use cases it can make sense to map a range with no privileges and later change the protection of the range from within a SIGSEGV handler when that address is accessed.

      mcc@mastodon.socialM kasperd@westergaard.socialK knowprose@mastodon.socialK artemist@social.mildlyfunctional.gayA 4 Replies Last reply
      0
      • kasperd@westergaard.socialK kasperd@westergaard.social

        You can use MAP_FIXED to get a range on a specific address. The address you specify that way does get rounded down to a multiple of the page size, but other than that it's used as is.

        A zero value for address has a special meaning, so if you absolutely want to map at address 0 you need to ask for address 1 rounded down. Though some kernels won't permit that in the default configuration.

        You can ask for more memory ahead of time. I am pretty sure the kernel only allocates the physical memory on the first write. However things get a little tricky with respect to over-commitment and such. As I understand it, the kernel will refuse the allocation if there is no way it could ever give you all of that memory. But I think the default is that when there is any doubt the kernel will let the allocation go through and kill the process later if it doesn't have memory after all. (I am not saying that's a good default.)

        There is also the possibility of allocating a memory range with no permissions and then use mprotect to make parts of the range read and writable later. In that case it would make sense to me if the kernel only updates the count of committed memory once you make it writable, I don't know if that's actually what happens, but it should be easy to test.

        I have used the approach of using mmap to allocate a range with no read or write permissions and then make a small range in the middle read-write with mprotect. My reason for using it has been to have guard pages around certain buffers as a security measure. It provides an extra layer of protection against buffer overflow vulnerabilities.

        For some advanced use cases it can make sense to map a range with no privileges and later change the protection of the range from within a SIGSEGV handler when that address is accessed.

        mcc@mastodon.socialM This user is from outside of this forum
        mcc@mastodon.socialM This user is from outside of this forum
        mcc@mastodon.social
        wrote last edited by
        #18

        @kasperd Thank you, this is not something I have read up on and is a great basis for future research. Here's an important question: Do *both* Linux mmap and the Windows equivalents offer these capabilities? Because my use cases invariably need to target both 😞

        knowprose@mastodon.socialK aeva@mastodon.gamedev.placeA kasperd@westergaard.socialK 3 Replies Last reply
        0
        • glyph@mastodon.socialG glyph@mastodon.social

          @mcc does daydreaming of a world where garbage collection is the operating system’s job count

          mcc@mastodon.socialM This user is from outside of this forum
          mcc@mastodon.socialM This user is from outside of this forum
          mcc@mastodon.social
          wrote last edited by
          #19

          @glyph Yes

          mcc@mastodon.socialM 1 Reply Last reply
          0
          • mcc@mastodon.socialM mcc@mastodon.social

            @glyph Yes

            mcc@mastodon.socialM This user is from outside of this forum
            mcc@mastodon.socialM This user is from outside of this forum
            mcc@mastodon.social
            wrote last edited by
            #20

            @glyph One thing I wonder is if we'd even need protected memory in that world. Per se. Or if we could throw out process protected memory and use the protected memory capabilities of the CPU for something entirely other

            glyph@mastodon.socialG 1 Reply Last reply
            0
            • kasperd@westergaard.socialK kasperd@westergaard.social

              You can use MAP_FIXED to get a range on a specific address. The address you specify that way does get rounded down to a multiple of the page size, but other than that it's used as is.

              A zero value for address has a special meaning, so if you absolutely want to map at address 0 you need to ask for address 1 rounded down. Though some kernels won't permit that in the default configuration.

              You can ask for more memory ahead of time. I am pretty sure the kernel only allocates the physical memory on the first write. However things get a little tricky with respect to over-commitment and such. As I understand it, the kernel will refuse the allocation if there is no way it could ever give you all of that memory. But I think the default is that when there is any doubt the kernel will let the allocation go through and kill the process later if it doesn't have memory after all. (I am not saying that's a good default.)

              There is also the possibility of allocating a memory range with no permissions and then use mprotect to make parts of the range read and writable later. In that case it would make sense to me if the kernel only updates the count of committed memory once you make it writable, I don't know if that's actually what happens, but it should be easy to test.

              I have used the approach of using mmap to allocate a range with no read or write permissions and then make a small range in the middle read-write with mprotect. My reason for using it has been to have guard pages around certain buffers as a security measure. It provides an extra layer of protection against buffer overflow vulnerabilities.

              For some advanced use cases it can make sense to map a range with no privileges and later change the protection of the range from within a SIGSEGV handler when that address is accessed.

              kasperd@westergaard.socialK This user is from outside of this forum
              kasperd@westergaard.socialK This user is from outside of this forum
              kasperd@westergaard.social
              wrote last edited by
              #21

              If you want to see truly absurd usage of some of the possibilities, there is this video on how one guy managed to achieve 17 592 722 915 310 recursive calls on the stack.

              - YouTube

              Auf YouTube findest du die angesagtesten Videos und Tracks. Außerdem kannst du eigene Inhalte hochladen und mit Freunden oder gleich der ganzen Welt teilen.

              favicon

              (www.youtube.com)

              1 Reply Last reply
              0
              • glyph@mastodon.socialG glyph@mastodon.social

                @mcc does daydreaming of a world where garbage collection is the operating system’s job count

                driusan@doomscroller.socialD This user is from outside of this forum
                driusan@doomscroller.socialD This user is from outside of this forum
                driusan@doomscroller.social
                wrote last edited by
                #22
                @glyph@mastodon.social @mcc@mastodon.social That's just called shell scripting.
                mcc@mastodon.socialM 1 Reply Last reply
                0
                • mcc@mastodon.socialM mcc@mastodon.social

                  Do you ever daydream about the incredibly wild optimizations a garbage collector could do if it had the direct control over virtual memory layout an operating system does

                  joe@f.duriansoftware.comJ This user is from outside of this forum
                  joe@f.duriansoftware.comJ This user is from outside of this forum
                  joe@f.duriansoftware.com
                  wrote last edited by
                  #23

                  @mcc i recently saw this, which i thought was a clever use of only userspace-level control over virtual memory layout https://github.com/plasma-umass/Mesh

                  dysfun@social.treehouse.systemsD 1 Reply Last reply
                  0
                  • driusan@doomscroller.socialD driusan@doomscroller.social
                    @glyph@mastodon.social @mcc@mastodon.social That's just called shell scripting.
                    mcc@mastodon.socialM This user is from outside of this forum
                    mcc@mastodon.socialM This user is from outside of this forum
                    mcc@mastodon.social
                    wrote last edited by
                    #24

                    @driusan @glyph what if shell scripting were good

                    1 Reply Last reply
                    0
                    • joe@f.duriansoftware.comJ joe@f.duriansoftware.com

                      @mcc i recently saw this, which i thought was a clever use of only userspace-level control over virtual memory layout https://github.com/plasma-umass/Mesh

                      dysfun@social.treehouse.systemsD This user is from outside of this forum
                      dysfun@social.treehouse.systemsD This user is from outside of this forum
                      dysfun@social.treehouse.systems
                      wrote last edited by
                      #25

                      @joe @mcc it's going to make a mess of your page tables though. i wouldn't actually deploy it.

                      joe@f.duriansoftware.comJ 1 Reply Last reply
                      0
                      • mcc@mastodon.socialM mcc@mastodon.social

                        @glyph One thing I wonder is if we'd even need protected memory in that world. Per se. Or if we could throw out process protected memory and use the protected memory capabilities of the CPU for something entirely other

                        glyph@mastodon.socialG This user is from outside of this forum
                        glyph@mastodon.socialG This user is from outside of this forum
                        glyph@mastodon.social
                        wrote last edited by
                        #26

                        @mcc on the one hand, in principle, of course not! you can validate everything once at the garbage collector level, put the GC in the kerrnel, use formal methods or whatever and bob's your uncle, everything would be so fast!

                        on the other hand, in practice, I have been in the room (usually at PyCon) where garbage collector bugs are being diagnosed and fixed, and from that experience, "no, this must never happen"

                        mcc@mastodon.socialM 1 Reply Last reply
                        0
                        • glyph@mastodon.socialG glyph@mastodon.social

                          @mcc on the one hand, in principle, of course not! you can validate everything once at the garbage collector level, put the GC in the kerrnel, use formal methods or whatever and bob's your uncle, everything would be so fast!

                          on the other hand, in practice, I have been in the room (usually at PyCon) where garbage collector bugs are being diagnosed and fixed, and from that experience, "no, this must never happen"

                          mcc@mastodon.socialM This user is from outside of this forum
                          mcc@mastodon.socialM This user is from outside of this forum
                          mcc@mastodon.social
                          wrote last edited by
                          #27

                          @glyph I've been thinking a lot in recent years about the unikernel environment

                          petrillic@hachyderm.ioP 1 Reply Last reply
                          0
                          • dysfun@social.treehouse.systemsD dysfun@social.treehouse.systems

                            @joe @mcc it's going to make a mess of your page tables though. i wouldn't actually deploy it.

                            joe@f.duriansoftware.comJ This user is from outside of this forum
                            joe@f.duriansoftware.comJ This user is from outside of this forum
                            joe@f.duriansoftware.com
                            wrote last edited by
                            #28

                            @dysfun @mcc yeah that was my thinking too, that seems to be the ultimate fate of most clever page table trickery (see also attempts to implement calloc() by mapping zeroed pages)

                            1 Reply Last reply
                            0
                            • mcc@mastodon.socialM mcc@mastodon.social

                              @glyph I've been thinking a lot in recent years about the unikernel environment

                              petrillic@hachyderm.ioP This user is from outside of this forum
                              petrillic@hachyderm.ioP This user is from outside of this forum
                              petrillic@hachyderm.io
                              wrote last edited by
                              #29

                              @mcc @glyph isn't this really the story of things like the Smalltalk and Lisp machines?

                              mcc@mastodon.socialM popeyeotaku@speedlines.stctp.zoneP 2 Replies Last reply
                              0
                              • petrillic@hachyderm.ioP petrillic@hachyderm.io

                                @mcc @glyph isn't this really the story of things like the Smalltalk and Lisp machines?

                                mcc@mastodon.socialM This user is from outside of this forum
                                mcc@mastodon.socialM This user is from outside of this forum
                                mcc@mastodon.social
                                wrote last edited by
                                #30

                                @petrillic @glyph I once got to see Dave Ungar using his laptop. It was a life-changing experience

                                petrillic@hachyderm.ioP 1 Reply Last reply
                                0
                                • mcc@mastodon.socialM mcc@mastodon.social

                                  @petrillic @glyph I once got to see Dave Ungar using his laptop. It was a life-changing experience

                                  petrillic@hachyderm.ioP This user is from outside of this forum
                                  petrillic@hachyderm.ioP This user is from outside of this forum
                                  petrillic@hachyderm.io
                                  wrote last edited by
                                  #31

                                  @mcc @glyph :wistful sigh: Self.

                                  glyph@mastodon.socialG 1 Reply Last reply
                                  0
                                  • petrillic@hachyderm.ioP petrillic@hachyderm.io

                                    @mcc @glyph :wistful sigh: Self.

                                    glyph@mastodon.socialG This user is from outside of this forum
                                    glyph@mastodon.socialG This user is from outside of this forum
                                    glyph@mastodon.social
                                    wrote last edited by
                                    #32

                                    @mcc @petrillic I am aware *that* Genera sort of petered out, but I still don't really understand *why* it did. It was too expensive for the hardware of the day, but probably *less* too-expensive than, say, NeXTSTEP, which famously endured despite a worse start. Has anyone written a history of Symbolics? I wonder if there are good reasons for this.

                                    petrillic@hachyderm.ioP 1 Reply Last reply
                                    0
                                    • glyph@mastodon.socialG glyph@mastodon.social

                                      @mcc @petrillic I am aware *that* Genera sort of petered out, but I still don't really understand *why* it did. It was too expensive for the hardware of the day, but probably *less* too-expensive than, say, NeXTSTEP, which famously endured despite a worse start. Has anyone written a history of Symbolics? I wonder if there are good reasons for this.

                                      petrillic@hachyderm.ioP This user is from outside of this forum
                                      petrillic@hachyderm.ioP This user is from outside of this forum
                                      petrillic@hachyderm.io
                                      wrote last edited by
                                      #33

                                      @glyph @mcc Asianometry did a video on the whole boom and bust of the industry. It was part of the AI winter that happened.

                                      - YouTube

                                      Auf YouTube findest du die angesagtesten Videos und Tracks. Außerdem kannst du eigene Inhalte hochladen und mit Freunden oder gleich der ganzen Welt teilen.

                                      favicon

                                      (www.youtube.com)

                                      glyph@mastodon.socialG ericcarroll@cosocial.caE 2 Replies Last reply
                                      0
                                      • petrillic@hachyderm.ioP petrillic@hachyderm.io

                                        @glyph @mcc Asianometry did a video on the whole boom and bust of the industry. It was part of the AI winter that happened.

                                        - YouTube

                                        Auf YouTube findest du die angesagtesten Videos und Tracks. Außerdem kannst du eigene Inhalte hochladen und mit Freunden oder gleich der ganzen Welt teilen.

                                        favicon

                                        (www.youtube.com)

                                        glyph@mastodon.socialG This user is from outside of this forum
                                        glyph@mastodon.socialG This user is from outside of this forum
                                        glyph@mastodon.social
                                        wrote last edited by
                                        #34

                                        @petrillic @mcc what promising technology will this one destroy, I wonder

                                        1 Reply Last reply
                                        0
                                        • mcc@mastodon.socialM mcc@mastodon.social

                                          Do you ever daydream about the incredibly wild optimizations a garbage collector could do if it had the direct control over virtual memory layout an operating system does

                                          aeva@mastodon.gamedev.placeA This user is from outside of this forum
                                          aeva@mastodon.gamedev.placeA This user is from outside of this forum
                                          aeva@mastodon.gamedev.place
                                          wrote last edited by
                                          #35

                                          @mcc now I am

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups