Skip to content

Implement wrappers for common syscalls #5

Closed

Description

@joneschrisg

From @rocallahan

  • gettimeofday
  • clock_gettime
  • read
  • write
  • poll
  • futex
  • (and maybe a few others)

Activity

  1. rocallahan commented on May 8, 2013

    @rocallahan
    Collaborator

    It's easy to collect counts of the number of syscalls by reading the rr trace files, especially for non-wrapped syscalls which are recorded in ASCII.

  2. joneschrisg commented on Jun 28, 2013

    @joneschrisg
    ContributorAuthor
    • futex

    As a note for posterity, glibc directly invokes futex; there's no unresolved symbol we can preload on top of. So we can't buffer it with our current approach. Shame.

  3. rocallahan commented on Jun 28, 2013

    @rocallahan
    Collaborator

    Any idea which symbols/how many symbols we'd need to override via LD_PRELOAD to catch most futex traffic?

  4. joneschrisg commented on Jun 28, 2013

    @joneschrisg
    ContributorAuthor

    I would guess that pthread_mutex_{lock, unlock} and cond_wait would get us the vast vast majority. Doing that is a little scary and nontrivial though. But it's relatively easy to quantify how worth doing it would be once we have the structure in place.

  5. joneschrisg commented on Jul 12, 2013

    @joneschrisg
    ContributorAuthor

    There are two measures that are interesting here: first is raw syscall count, which is easy to measure. The second is syscalls that "break the chain". For example, if gettimeofday is one of the top syscalls, we should buffer it, but if 1/3 of the time it's followed by stat say, then the buffering won't be as effective. We'd want to buffer stat too.

  6. joneschrisg commented on Jul 12, 2013

    @joneschrisg
    ContributorAuthor

    On a small representative Firefox workflow, histogram-trace says the top 10 are

    syscall count
    ------- -----
      78    145704  (gettimeofday)
     265    128062  (clock_gettime)
     240     31596  (futex)
     102     28834  (socketcall)
     168     19642  (poll)
       3     18464  (read)
     219      9700  (madvise???)
       4      7446  (write)
     221      7016  (fcntl64)
       5      6694  (open)
    ...
    

    This pretty much matches historical data. Unfortunately futex and socketcall are giant pains in the butt to support, but looks like we'll want to. The rest are trivial though.

  7. joneschrisg commented on Jul 12, 2013

    @joneschrisg
    ContributorAuthor

    219 9700 (madvise???)

    This seems to be coming from a *Monkey [1] JIT. So not so surprising.

    [1] I just realized I don't know what monkey FF is on anymore! sniffle

  8. joneschrisg commented on Jul 12, 2013

    @joneschrisg
    ContributorAuthor

    The desched event, which was working so well in early testing, ain't doing so well with FF. I added wrappers for the easy syscalls above (futex, socketcall, and fcntl are hard), and FF blows up. However, when I was able to get a run that avoided the landmines, FF recorded about 10% faster just from wrapping poll (loading the start page). That's good news.

    The wrapper for open also doesn't seem to be working all the time. rr ends up processing a significant number of open syscalls, even though we do sometimes hit the open wrapper, and the buffer isn't full. Needs investigation. However, even without wrapping all the open calls, FF is about 5% faster with the wrapper. That's also great news.

  9. joneschrisg commented on Jul 15, 2013

    @joneschrisg
    ContributorAuthor

    The desched event turned out to still be working just fine, only a recent commit regressed it embarrassingly. I guess that's what happens when effectively dead code is committed. The basic syscalls above, sans poll too now, are working. Just needs some cleanup before commit. poll is proving to be a bit of a pain, and the work here is starting to pile up, so splitting that out into a followup.

  10. joneschrisg commented on Jul 16, 2013

    @joneschrisg
    ContributorAuthor

    Testing shows that close and writev might be worth buffering. The latter is used by xlib, IIRC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions