Skip to content
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

Improve protected files performance #1599

Open
yao-ji opened this issue Oct 10, 2023 · 3 comments · May be fixed by #1681
Open

Improve protected files performance #1599

yao-ji opened this issue Oct 10, 2023 · 3 comments · May be fixed by #1681
Assignees
Labels
enhancement New feature or request P: 2

Comments

@yao-ji
Copy link
Contributor

yao-ji commented Oct 10, 2023

Description of the feature

Current implementation of protected file is slow, especially for large files. At least the following 2 improvements can be applied.

  1. Use file map to replace read/write a single node from/to disk.
  2. Remove the encrypted part inside the file_node_t structure. The encrypted content can be directly retrieved from disk. The encryption/decryption functions can use the file mapped addresses instead so we can save the cache memory as well as the time used to copy it to/from disk.

Why Gramine should implement it?

Performance test on SGX SDK shows that applying these two changes can make reading 2 times fasters and writing 7 times faster.

@dimakuv
Copy link

dimakuv commented Oct 10, 2023

Looks like reasonable optimizations.

@dimakuv
Copy link

dimakuv commented Oct 31, 2023

@yao-ji Is this something that you want to work on?

@yao-ji
Copy link
Contributor Author

yao-ji commented Nov 1, 2023

@yao-ji Is this something that you want to work on?

Yes. And I have collected some data about time can be saved after applying the changes.

Since there is no need to call g_cb_read and g_cb_write in reading/writing each node, we calculate how much time these two call backs used inside each read/write syscall. Note that the write syscall performs both ipf_write and ipf_internal_flush, so we will add the time used of these two together. The test code can be found here.

<style> </style>
File size 8KB 32KB 128KB 512KB 2MB 8MB 32MB
write time used (ns) 3453 8765 29800 118334 497853 1942698 8032618
write time saved (ns) 536 1307 4208 17014 70953 279094 1109268
saved percentage 15.5227% 14.9116% 14.1208% 14.3779% 14.2518% 14.3663% 13.8095%
               
read time used (ns) 1627 5958 25457 95566 417476 1591918 6287079
read time saved (ns) 160 257 681 2408 9459 36452 151601
saved percentage 9.8341% 4.3135% 2.6751% 2.5197% 2.2658% 2.2898% 2.4113%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P: 2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants