gramine icon indicating copy to clipboard operation
gramine copied to clipboard

Page Cache support for trusted files

Open jkr0103 opened this issue 1 year ago • 0 comments

Description of the changes

Please check issue #1712 for details.

This PR introduces a manifest option sgx.tf_max_chunks_in_cache which specifies the sub-region of each trusted file is cached if the file is opened more than 10 times. Cache eviction policy is Least Recently Used aka LRU. This optimization is used when there are frequently-reused files.

Downside of this optimization: If the files are rarely reused, then this optimization unnecessarily fills out enclave memory. and if there are too many files, then too much memory will be spent on the cache.

Below are the results with and without this PR for nginx run:

Marit Threads Native SGX (without page cache) SGX (with page cache) Degradation without page cache Degradation with page cache
Requests/sec 64 930275 29030 817008 97% 12%

Fixes #1712

How to test this PR?

Change worker_processes value to auto in CI-Examples/nginx/nginx-gramine.conf.template Add open_file_cache max=1024 inactive=10s; under http { block in CI-Examples/nginx/nginx-gramine.conf.template

cd gramine/CI-Examples/nginx
make clean && make SGX=1

Native run:

./install/sbin/nginx -c conf/nginx-gramine.conf
wrk -t64 -c300 -d30s http://127.0.0.1:8002/random/10K.1.html

SGX run:

gramine-sgx nginx
wrk -t64 -c300 -d30s http://127.0.0.1:8002/random/10K.1.html

Initial 1-3 run with gramine-sgx might give low performance results as trusted file chuks are added to the page cache for the first time. After 1-3 iterations results become consistent.


This change is Reviewable

jkr0103 avatar Feb 22 '24 11:02 jkr0103