-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Backtracing] Add a caching wrapper for MemoryReader. #69510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
@swift-ci Please smoke test |
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
0cf803e
to
8ca4b68
Compare
Hah. Build failed because of something I'd already fixed but failed to push. Let's try that again. |
@swift-ci Please smoke test |
3d7900a
to
997b9dc
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
028bbab
to
98a800c
Compare
Rebased on top of #69508. |
@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
98a800c
to
9aac812
Compare
Rebased again. |
@swift-ci Please smoke test |
When I rebased, I didn't get the FileImageSource code quite right. rdar://117681625
@swift-ci Please smoke test |
@swift-ci Please smoke test macOS platform |
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