rr-debugger / rr-debugger/rr

Improving thread creation performance

Open
#3,420 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.7k
Forks
662
Avg merge
2d 3h
Merged PRs (30d)
2

Description

I'm looking at a large application which creates absurd numbers of threads during startup. I'd like to reduce the overhead of this code under rr. Measuring the thread_stress test suggests that creating a thread that does practically nothing but exit takes about 5ms under rr on my machine.

The key problem seems to be the work we have to do to get syscallbuf set up for each thread. This is basically:

  • 2 round trips to rr for gettid enter/exit (syscallbuf)
  • 2 round trips to rr for perf_event_open enter/exit (syscallbuf)
  • 2 round trips to rr for fcntl dup enter/exit (syscallbuf)
  • 2 round trips to rr for rrcall_init_buffers (syscallbuf)
    • 3 round trips to tracee (recvmsg, mmap, close) for Session::create_shared_mmap
    • 4 round trips to tracee (sendmsg desched fd, recvmsg/dup3/close clonedata fd) for RecordTask::init_buffers_arch

That's 15 round trips, i.e. 30 context switches, in code we control.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the thread_stress test and trace the syscallbuf setup described in the issue, including rrcall_init_buffers, Session::create_shared_mmap, and RecordTask::init_buffers_arch. Measure the thread-creation round trips under rr before and after the change; done means materially lower overhead for threads that immediately exit.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
devtools, operating-systems, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.