Re: [Fwd: Some mmap observations compared to Linux 2.6/OpenBSD]

From: Alan Cox (alc_at_cs.rice.edu)
Date: 10/27/03

  • Next message: Dan Nelson: "Re: FreeBSD 4.2 NIS-Client with Linux NIS-Server Problem"
    Date: Sun, 26 Oct 2003 17:09:37 -0600
    To: Q <q@onthenet.com.au>, hackers@freebsd.org
    
    

    On Wed, Oct 22, 2003 at 01:34:01PM +1000, Q wrote:
    > It has been suggested that I should direct this question to the VM
    > system guru's. Your comments on this would be appreciated.
    >

    An address space is represented by a data structure that we call a
    vm_map. A vm_map is, in the abstact, an ordered collection of in-use
    address ranges.

    FreeBSD 4.x implements the vm_map as a doubly-linked list of address
    ranges with a hint pointing to the last accessed entry. Thus, if the
    hint fails, the expected time to lookup an in-use address is O(n).
    FreeBSD 5.x overlays a balanced binary search tree over this
    structure. This accelerates the lookup to an (amortized) O(log n).
    In fact, for the kind of balanced binary search tree that we use, the
    last accessed entry is at the root of the tree. Thus, any locality in
    the pattern of lookups will produce even better results.

    Linux and OpenBSD are similar to FreeBSD 5.x. The differences lie in
    the details, like the kind of balanced binary tree that is used.

    That said, having a balanced binary tree to represent the address
    space does NOT inherently make finding unallocated space any faster.
    Instead, OpenBSD augments an address space entry with extra
    information to speed up this process:

    struct vm_map_entry {
            ...
            vaddr_t ownspace; /* free space after */
            vaddr_t space; /* space in subtree */
            ...

    The same could be done in FreeBSD, and you don't need a red-black tree
    in order to do it.

    If someone, especially a junior kernel hacker with a commit bit, is
    serious about trying this, I'll gladly mentor them. Recognize,
    however, that this approach may produce great results for a
    microbenchmark, but pessimize other more interesting workloads,
    like say, "buildworld", making it a poor choice. Nonetheless, I think
    we should strive to get better results in this area.

    Regards,
    Alan

    >
    > -----Forwarded Message-----
    > From: Q <q@onthenet.com.au>
    > To: freebsd-hackers@freebsd.org
    > Subject: Some mmap observations compared to Linux 2.6/OpenBSD
    > Date: Wed, 22 Oct 2003 12:22:35 +1000
    >
    > As an effort to get more acquainted with the FreeBSD kernel, I have been
    > looking through how mmap works. I don't yet understand how it all fits
    > together, or of the exact implications things may have in the wild, but
    > I have noticed under some synthetic conditions, ie. mmaping small
    > non-contiguous pages of a file, mmap allocation scales much more poorly
    > on FreeBSD than on OpenBSD and Linux 2.6.
    >
    > After investigating this further I have observed that vm_map_findspace()
    > traverses a linked list to find the next region (O(n) cost), whereas
    > OpenBSD and Linux 2.6 both use Red-Black trees for the same purpose
    > (O(log n) cost). Profiling the FreeBSD kernel appears to confirm this.
    >
    > Can someone comment on whether this is something that has been done
    > intentionally, or avoided in favour of some other yet to be implemented
    > solution? Or is it still on someones todo list.
    >
    > --
    > Seeya...Q
    >
    > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    >
    > _____ / Quinton Dolan - q@OntheNet.com.au
    > __ __/ / / __/ / /
    > / __ / _/ / / Gold Coast, QLD, Australia
    > __/ __/ __/ ____/ / - / Ph: +61 419 729 806
    > _______ /
    > _\
    >
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Dan Nelson: "Re: FreeBSD 4.2 NIS-Client with Linux NIS-Server Problem"

    Relevant Pages

    • [FreeBSD-Announce] FreeBSD Status Report Fourth Quarter 2006
      ... FreeBSD 6.2 is finally out of the door ... see the "Open tasks" sections for more information. ... Some major work is currently going on in the main BSNMP tree: ... Merge MAC Framework hooks allowing MAC modules to control access ...
      (freebsd-announce)
    • FreeBSD Status Report Fourth Quarter 2006
      ... FreeBSD Status Report ... see the "Open tasks" sections for more information. ... Some major work is currently going on in the main BSNMP tree: ... Merge MAC Framework hooks allowing MAC modules to control access ...
      (freebsd-current)
    • FreeBSD Status Report Fourth Quarter 2006
      ... FreeBSD Status Report ... see the "Open tasks" sections for more information. ... Some major work is currently going on in the main BSNMP tree: ... Merge MAC Framework hooks allowing MAC modules to control access ...
      (freebsd-hackers)
    • Re: FreeBSDs problems as seen by the BSDForen.de community
      ... You cannot force a _volunteer_ to work on anything ... FreeBSD is mostly a project of volunteers, ... tree, ... They waste it on whatever they want, no matter ...
      (freebsd-current)
    • Re: Fwd: That whole "Linux stealing our code" thing
      ... The myth that Theo understands dual licensing? ... It's no longer dual licenced in the FreeBSD tree because the FreeBSD ... FreeBSD doesn't have Reyk's athHAL from OpenBSD, ... dual licenced files planned to make GPL-only ...
      (Linux-Kernel)