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

[PAL/Linux-SGX] Remove printing of thread-local SGX statistics #1995

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

dimakuv
Copy link
Contributor

@dimakuv dimakuv commented Sep 4, 2024

Description of the changes

Previously, when manifest contained sgx.enable_stats = true, Gramine-SGX printed not the process-wide SGX statistics, but also statistics for each thread. These thread-local SGX statistics only litter the output as (1) there are helper Gramine threads that do not correspond to any application thread, (2) there is no way to correlate the printed thread-local stats to application threads/workload execution (as stats simply print the opaque TID of the thread).

This PR removes thread-local stats and keeps only process-wide ones.

How to test this PR?

The Helloworld CI example (with sgx.enable_stats = true):

  • With this PR:
gramineproject/gramine/CI-Examples/helloworld$ gramine-sgx helloworld
Gramine is starting. Parsing TOML manifest file, this may take some time...
----- SGX enclave loading time =     412964 microseconds -----
-----------------------------------------------------------------------------------------------------------------------
Gramine detected the following insecure configurations:

  - sgx.debug = true                           (this is a debug enclave)

Gramine will continue application execution, but this configuration must not be used in production!
-----------------------------------------------------------------------------------------------------------------------

Hello, world
----- Total SGX stats for process 273134 -----
  # of EENTERs:        317
  # of EEXITs:         241
  # of AEXs:           2175
  # of sync signals:   72
  # of async signals:  0
  • Without this PR:
gramineproject/gramine/CI-Examples/helloworld$ gramine-sgx helloworld
Gramine is starting. Parsing TOML manifest file, this may take some time...
----- SGX enclave loading time =     410795 microseconds -----
-----------------------------------------------------------------------------------------------------------------------
Gramine detected the following insecure configurations:

  - sgx.debug = true                           (this is a debug enclave)

Gramine will continue application execution, but this configuration must not be used in production!
-----------------------------------------------------------------------------------------------------------------------

----- SGX stats for thread 323750 -----
  # of EENTERs:        15
  # of EEXITs:         14
  # of AEXs:           19
  # of sync signals:   0
  # of async signals:  0
----- SGX stats for thread 323751 -----                                                                               [0/1860]
  # of EENTERs:        15
  # of EEXITs:         14
  # of AEXs:           0
  # of sync signals:   0
  # of async signals:  0
----- SGX stats for thread 323753 -----
  # of EENTERs:        15
  # of EEXITs:         14
  # of AEXs:           0
  # of sync signals:   0
  # of async signals:  0
Hello, world
----- SGX stats for thread 323754 -----
  # of EENTERs:        3
  # of EEXITs:         2
  # of AEXs:           0
  # of sync signals:   0
  # of async signals:  0
----- SGX stats for thread 323683 -----
  # of EENTERs:        269
  # of EEXITs:         197
  # of AEXs:           2162
  # of sync signals:   72
  # of async signals:  0
----- Total SGX stats for process 323683 -----
  # of EENTERs:        317
  # of EEXITs:         241
  # of AEXs:           2181
  # of sync signals:   72
  # of async signals:  0

This change is Reviewable

Copy link
Contributor Author

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel)

a discussion (no related file):
@mkow @woju @jkr0103 @kailun-qin @mwkmwkmwk What do you think about this PR? It changes user-facing (profiling) output, do we care? I am 99.9% sure no users rely on thread-local outputs.


Copy link
Contributor Author

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners

a discussion (no related file):

Previously, dimakuv (Dmitrii Kuvaiskii) wrote…

@mkow @woju @jkr0103 @kailun-qin @mwkmwkmwk What do you think about this PR? It changes user-facing (profiling) output, do we care? I am 99.9% sure no users rely on thread-local outputs.

Feedback from @aneessahib: there were workloads where thread-local statistics were useful in debugging. However, hopefully with #1996 (the ability to reset stats on a user signal), the debugging with process-wide-only statistics will be similarly useful. So @aneessahib is Ok with both options: merging this PR and removing it.


kailun-qin
kailun-qin previously approved these changes Sep 11, 2024
Copy link
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions, not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @aneessahib, @dimakuv, @jkr0103, @mkow, @mwkmwkmwk, and @woju)

a discussion (no related file):

there were workloads where thread-local statistics were useful in debugging

Yep, I guess so. But I'm fine w/ this PR.



-- commits line 5 at r2:
-> not only?

Code quote:

not

Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions, not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @aneessahib, @dimakuv, @jkr0103, @mwkmwkmwk, and @woju)


-- commits line 8 at r2:

Suggestion:

there is no easy way

pal/src/host/linux-sgx/host_ocalls.c line 63 at r2 (raw file):

    if (ocall_exit_args->is_exitgroup) {
        process_exit((int)ocall_exit_args->exitcode);
        die_or_inf_loop();

process_exit() is already noreturn


pal/src/host/linux-sgx/pal_tcb.h line 118 at r2 (raw file):

extern bool g_sgx_enable_stats;
void update_sgx_stats(bool print_process_wide_stats);

Suggestion:

do_print

Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 6 unresolved discussions, not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @aneessahib, @dimakuv, @jkr0103, @mwkmwkmwk, and @woju)

a discussion (no related file):

Enabling per-thread and process-wide SGX stats

manifest-syntax.rst also needs an update.


Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 6 unresolved discussions, not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @aneessahib, @dimakuv, @jkr0103, @mwkmwkmwk, and @woju)

a discussion (no related file):

Previously, mkow (Michał Kowalczyk) wrote…

Enabling per-thread and process-wide SGX stats

manifest-syntax.rst also needs an update.

ah, and performance.rst also


Copy link
Contributor Author

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 5 unresolved discussions, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: Intel), "fixup! " found in commit messages' one-liners (waiting on @dimakuv, @kailun-qin, @mkow, and @woju)

a discussion (no related file):

Previously, mkow (Michał Kowalczyk) wrote…

ah, and performance.rst also

Done. Good catch.



-- commits line 5 at r2:

Previously, kailun-qin (Kailun Qin) wrote…

-> not only?

Will do during final rebase


-- commits line 8 at r2:
Will do during final rebase


pal/src/host/linux-sgx/host_ocalls.c line 63 at r2 (raw file):

Previously, mkow (Michał Kowalczyk) wrote…

process_exit() is already noreturn

Done.


pal/src/host/linux-sgx/pal_tcb.h line 118 at r2 (raw file):

extern bool g_sgx_enable_stats;
void update_sgx_stats(bool print_process_wide_stats);

Done.

Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions, "fixup! " found in commit messages' one-liners (waiting on @dimakuv and @woju)

Copy link
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions, "fixup! " found in commit messages' one-liners (waiting on @dimakuv and @woju)

Previously, when manifest contained `sgx.enable_stats = true`,
Gramine-SGX printed not only the process-wide SGX statistics, but also
statistics for each thread. These thread-local SGX statistics only
litter the output as (1) there are helper Gramine threads that do not
correspond to any application thread, (2) there is no easy way to
correlate the printed thread-local stats to application threads/workload
execution (as stats simply print the opaque TID of the thread).

This commit removes thread-local stats and keeps only process-wide ones.

Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
@dimakuv dimakuv force-pushed the dimakuv/sgx-stats-rm-thread-local-prints branch from f66ba21 to 2ff0ab1 Compare September 24, 2024 14:15
Copy link
Contributor Author

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 5 files reviewed, 2 unresolved discussions (waiting on @kailun-qin, @mkow, and @woju)


-- commits line 5 at r2:

Previously, dimakuv (Dmitrii Kuvaiskii) wrote…

Will do during final rebase

Done.


-- commits line 8 at r2:

Previously, dimakuv (Dmitrii Kuvaiskii) wrote…

Will do during final rebase

Done.

Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @woju)

Copy link
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @woju)

@dimakuv dimakuv merged commit 2ff0ab1 into master Sep 24, 2024
18 checks passed
@dimakuv dimakuv deleted the dimakuv/sgx-stats-rm-thread-local-prints branch September 24, 2024 16:54
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.

3 participants