Skip to content

[SourceKit] Avoid one memcpy on potentially big sourcekit response data #30929

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

Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 9, 2020

A kind indicator is needed before the actual data when custom data are stored as xpc dictionary values. Instead of prepending the kind bit by copying data to another buffer, let the data producers include it in the created data.

@rintaro rintaro requested review from akyrtzi and benlangmuir April 9, 2020 20:53
@rintaro
Copy link
Member Author

rintaro commented Apr 9, 2020

@swift-ci Please test

Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@swift-ci
Copy link
Contributor

swift-ci commented Apr 9, 2020

Build failed
Swift Test Linux Platform
Git Sha - 90020fa8a2663cd28ba700ff7038fa57393d6158

@rintaro rintaro force-pushed the sourcekit-setcustombuffer-avoidmemcopy branch from 69478e1 to 8a5b4ff Compare April 9, 2020 23:43
@rintaro
Copy link
Member Author

rintaro commented Apr 9, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 9, 2020

Build failed
Swift Test Linux Platform
Git Sha - 90020fa8a2663cd28ba700ff7038fa57393d6158

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 90020fa8a2663cd28ba700ff7038fa57393d6158

@rintaro
Copy link
Member Author

rintaro commented Apr 10, 2020

@swift-ci Please test Linux


char *start = result->getBufferStart();
char *start = result->getBufferStart() + sizeof(uint64_t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: + kindSize

BufferPtr(llvm::MemoryBuffer::getMemBufferCopy(
MemBuf->getBuffer(),
MemBuf->getBufferIdentifier()))
SKDCustomData(std::unique_ptr<llvm::MemoryBuffer>& MemBuf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are changing this from copying the buffer to taking ownership of it, so the type should be rvalue reference (&&) or else by value, not by lvalue reference.

A kind indicator is needed before the actual data when custom data are
storeed as xpc dictionary values. Instead of prepending the kind bit by
copying data to another buffer, let the data producers include it in the
created data.
@rintaro rintaro force-pushed the sourcekit-setcustombuffer-avoidmemcopy branch from 8a5b4ff to 69971af Compare April 10, 2020 18:30
@rintaro
Copy link
Member Author

rintaro commented Apr 10, 2020

@swift-ci Please smoke test

@shahmishal
Copy link
Member

@swift-ci Please smoke test windows

@rintaro rintaro merged commit fbb7bfc into swiftlang:master Apr 10, 2020
@rintaro rintaro deleted the sourcekit-setcustombuffer-avoidmemcopy branch April 10, 2020 20:15
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.

5 participants