[LibOS] Add Page Cache feature for trusted files
check issue #1712 for details.
This PR introduces a manifest option sgx.trusted_files_cache_size which specifies the cache size allocated for trusted files. A 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.
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 | 965844 | 386647 | 759754 | 60% | 21% |
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 chunks are added to the page cache for the first time. After 1-3 iterations results become consistent.