[lkml]   [2003]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subject/proc reliability & performance
    I created a process with 360 thousand threads,
    went into the /proc/*/task directory, and did
    a simple /bin/ls. It took over 9 minutes on a
    nice fast Opteron. (it's the same at top-level
    with processes, but I wasn't about to mess up
    my system that much)

    OK, that's a bit extreme, but it does show a
    scalability problem. There is an O(n*n)
    algorithm in there. Here is a proposed fix:

    Tie directory readers to a task_struct (or to
    some of the PID tracking structs), so that
    a directory reader is on a list. When a task
    exits, move the list of directory readers on
    to a neighboring task.

    That is O(1) on task exit, and generally O(n)
    for the whole /proc or /proc/42/task read.
    It's O(1) per step of the read, excepting
    where multiple directory readers wind up at
    the same location.

    Another benefit is that it is reliable as
    long as tasks don't move around on the lists.
    Each task will appear at most once, and will
    appear exactly once if it doesn't start or
    exit during the directory scan.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:58    [W:0.019 / U:9.560 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site