Commit Graph

22 Commits

Author SHA1 Message Date
Gunnar Beutner
9444272ba0 Profiler: Remove m_deepest_stack_depth
This isn't used anymore so let's remove it entirely.
2021-06-03 01:16:32 +01:00
Gunnar Beutner
a607f13fc7 Profiler: Use sequential serial numbers for profiling events
Previously Profiler was using timestamps to distinguish processes.
However it is possible that separate processes with the same PID exist
at the exact same timestamp (e.g. for execve). This changes Profiler
to use unique serial numbers for each event instead.
2021-06-03 01:16:32 +01:00
Andreas Kling
8a5c78e93b Profiler: Split the call tree into one subtree per process
This patch adds an additional level of hierarchy to the call tree:
Every process gets its own top-level node. :^)

Before this, selecting multiple processes would get quite confusing
as all the call stacks from different processes were combined together
into one big tree.
2021-05-22 22:23:52 +02:00
Lenny Maiorani
6ac454e70a DevTools: Remove redundant default destructor and forward declarations
Problem:
- Default destructors (and constructors) are in `.cpp` files. This
  prevents the compiler's optimizer from inlining them when it thinks
  inlining is appropriate (unless LTO is used).
- Forward declarations can prevent some optimizations, such as
  inlining of constructors and destructors.

Solution:
- Remove them or set them to `= default` and let the compiler handle
  the generation of them.
- Remove unneeded forward declarations.
2021-05-21 22:53:33 +01:00
Gunnar Beutner
6ac1ca5a9a Profiler: Remove ability to filter Kernel::Scheduler::yield() frames
Hiding those frames doesn't really make sense. They're a major
contributor to a process' spent CPU time and show up in a lot of
profiles. That however is because those processes really do spend
quite a bit of time in the scheduler by doing lots of context
switches, like WindowServer when responding to IPC calls.

Instead of hiding these for aesthetic reasons we should instead
improve the scheduler.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
c41f13f10b Kernel+Profiler: Track lost time between profiler timer ticks
We can lose profiling timer events for a few reasons, for example
disabled interrupts or system slowness. This accounts for lost
time between CPU samples by adding a field lost_samples to each
profiling event which tracks how many samples were lost immediately
preceding the event.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
d6b3513aab Profiler: Let the user ignore context switches
Now that the profiling timer is independent from the scheduler the
user will get quite a few CPU samples from "within" the scheduler.
These events are less useful when just profiling a user-mode process
rather than the whole system. This patch adds an option to Profiler to
hide these events.
2021-05-14 00:35:57 +02:00
Gunnar Beutner
210d2d270d Profiler: Let the user select more than one process 2021-05-08 09:53:53 +02:00
Gunnar Beutner
2d6091be10 Profiler: Move filter checks into their own function 2021-05-07 15:26:51 +02:00
Andreas Kling
dbbc6096a9 Profiler: Move everything into the "Profiler" namespace 2021-05-04 20:59:32 +02:00
Gunnar Beutner
eb798d5538 Kernel+Profiler: Improve profiling subsystem
This turns the perfcore format into more a log than it was before,
which lets us properly log process, thread and region
creation/destruction. This also makes it unnecessary to dump the
process' regions every time it is scheduled like we did before.

Incidentally this also fixes 'profile -c' because we previously ended
up incorrectly dumping the parent's region map into the profile data.

Log-based mmap support enables profiling shared libraries which
are loaded at runtime, e.g. via dlopen().

This enables profiling both the parent and child process for
programs which use execve(). Previously we'd discard the profiling
data for the old process.

The Profiler tool has been updated to not treat thread IDs as
process IDs anymore. This enables support for processes with more
than one thread. Also, there's a new widget to filter which
process should be displayed.
2021-04-26 17:13:55 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
1208fc7d37 AK: Simplify Bitmap and implement in terms of BitmapView
Add Bitmap::view() and forward most of the calls to BitmapView since
the code was identical.

Bitmap is now primarily concerned with its dynamically allocated
backing store and BitmapView deals with the rest.
2021-03-04 11:25:45 +01:00
Andreas Kling
373a595c56 Profiler: Symbolicate addresses in non-PIE ELF objects
This is a little bit messy, but basically if an ELF object is non-PIE,
we have to account for the executable mapping being at a hard-coded
offset and subtract that when doing symbolication.

There's probably a nicer way to solve this, I just hacked this together
so we can see "cc1plus" and friends in profiles. :^)
2021-03-03 23:13:26 +01:00
Andreas Kling
0fc3983c8d Profiler: Cache and reuse mapped ELF objects
In multi-process profiles, the same ELF objects tend to occur many
times (everyone has libc.so for example) so we will quickly run out
of VM if we map each object once per process that uses it.

Fix this by adding a "mapped object cache" that maps the path of
an ELF object to a cached memory mapping and wrapping ELF::Image.
2021-03-03 22:57:45 +01:00
Andreas Kling
5e7abea31e Kernel+Profiler: Capture metadata about all profiled processes
The perfcore file format was previously limited to a single process
since the pid/executable/regions data was top-level in the JSON.

This patch moves the process-specific data into a top-level array
named "processes" and we now add entries for each process that has
been sampled during the profile run.

This makes it possible to see samples from multiple threads when
viewing a perfcore file with Profiler. This is extremely cool! :^)
2021-03-02 22:38:06 +01:00
thislooksfun
225baa3cb7 Profiler: remove unimplemented Profile::LibraryMetadata::symbolicate() definition
The implementation of Profile::LibraryMetadata::symbolicate() was
removed in 340180ba05, but the
corresponding public declaration was not.
2021-02-28 15:28:08 +01:00
Andreas Kling
1fb1279cfd Profiler: Add a new "Samples" view to the main UI
You can now view the individual samples in a profile one by one with
the new "Samples" view. The "old" main view moves into a "Call Tree"
tab (but it remains the default view.)

When you select a sample in the samples view, we show you the full
symbolicated backtrace in a separate view on the right hand side. :^)
2021-02-27 18:34:21 +01:00
Andreas Kling
340180ba05 Profiler: Move ELF object name to its own profile graph column
This way you don't have to look at all the library names if you don't
want to. Since we're pretty good about namespacing our things, the
library names are slightly redundant information.
2021-02-27 17:45:41 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
4055b03291 DevTools: Move to Userland/DevTools/ 2021-01-12 12:18:55 +01:00