Skip to content

Conversation

al45tair
Copy link
Contributor

Currently we read many small chunks from the process we're backtracing. If it so happens that it's the local process, that isn't really a big problem, but if it's a remote process, especially on Linux where we have to use the memory server, it's probably a little slow.

Fix by adding a caching layer.

rdar://117681625

On Linux we use FileImageSource to read data from ELF images.  We were
doing this in a fairly naive manner, which turns out to be a performance
issue with larger statically linked binaries on Linux.

Change FileImageSource to use mmap() instead.

rdar://117590155
@al45tair al45tair requested a review from mikeash October 30, 2023 16:22
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

This will conflict with #69508; we'll need to update (probably this one) after that one lands.

We don't really need it after calling `mmap()`, and not keeping it around
means it's easy to make sure it gets closed properly in all cases.

rdar://117590155
@al45tair
Copy link
Contributor Author

Hah. Build failed because of something I'd already fixed but failed to push. Let's try that again.

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@al45tair
Copy link
Contributor Author

al45tair commented Nov 1, 2023

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Nov 2, 2023

Rebased on top of #69508.

@al45tair
Copy link
Contributor Author

al45tair commented Nov 2, 2023

@swift-ci Please smoke test

It was pointed out that there was a more Swift-y way to write the
bounds checks for the `fetch<T>` implementation, so do that instead.

rdar://117590155
Currently we read many small chunks from the process we're backtracing.
If it so happens that it's the local process, that isn't really a big
problem, but if it's a remote process, especially on Linux where we have
to use the memory server, it's probably a little slow.

Fix by adding a caching layer.

rdar://117681625
Because the cache uses the page addresses as its keys, we should have
a precondition to check that we haven't passed an address within a page.
The latter would result in confusing behaviour so it's worth diagnosing
up front.

rdar://117681625
It turns out that .copyBytes() checks that the source doesn't provide more
bytes than the destination will accept.

rdar://117681625
@al45tair
Copy link
Contributor Author

al45tair commented Nov 3, 2023

Rebased again.

@al45tair
Copy link
Contributor Author

al45tair commented Nov 3, 2023

@swift-ci Please smoke test

When I rebased, I didn't get the FileImageSource code quite right.

rdar://117681625
@al45tair
Copy link
Contributor Author

al45tair commented Nov 6, 2023

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Nov 6, 2023

@swift-ci Please smoke test macOS platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants