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

[browser] single threaded diagnostic server #111910

Merged
merged 22 commits into from
Feb 20, 2025

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Jan 28, 2025

This is split from #110818 to make code review easier

Enabled by <FeaturePerfTracing>true</FeaturePerfTracing>

Single thread

  • ep_rt_thread_create and ep_rt_thread_mono_start_func
    • it will run short, non-blocking jobs on the browser event loop instead of on dedicated threads
    • streaming_loop_tick refactored from streaming_thread
    • server_loop_tick from refactored server_thread
  • mono_wasm_ds_exec to process on tick on event loop
  • mono_schedule_ds_job will register callback into queue for above
  • NOOP implementation of ep_rt_wait_event_wait
  • new FEATURE_PERFTRACING_DISABLE_THREADS -> PERFTRACING_DISABLE_THREADS
  • ds_ipc_stream_factory_get_next_available_stream only polls once and never blocks

Sampling

  • disabled sampling_thread because we can't do "stop-the-world and scan other threads"
  • new events ep_rt_sample_profiler_enabled and ep_rt_sample_profiler_disabled
  • new ep_rt_mono_sampling_provider_component_init
    • install mono profiler instrumentation MONO_PROFILER_CALL_INSTRUMENTATION_ENTER
    • this needs to happen before any managed code is executed
  • it has negative performance impact when workload & re-linked with FeaturePerfTracing
    • this is just single condition per method enter (and later per safe-point)
    • we could introduce separate FeaturePerfTracingSampling to enable/disable this if necessary

Web socket

  • FEATURE_PERFTRACING_PAL_WS
  • ds-ipc-pal-websocket.c and ds-ipc-pal-websocket.h they just forward to JavaScript
  • empty for now ds_rt_websocket_create, ds_rt_websocket_send, ds_rt_websocket_poll, ds_rt_websocket_recv, ds_rt_websocket_close

Other

  • include diagnostics_tracing-static.a in in-tree builds
  • Microsoft.NETCore.App.Runtime.Mono.perftrace.**RID** cleanup
  • fix SystemNative_GetCpuUtilization
  • fix crash dump file permissions for CI/helix

Next PRs

  • the rest of the implementation in JavaScript, for WebSocket and JS client
  • better sampling instrumentation via MINT_SDB_SEQ_POINT or similar
  • tests

Out of scope

  • pause runtime during startup
  • multi-threaded EP on browser - this will need some cross thread marshaling

contributes to #76316

wip

Verified

This commit was signed with the committer’s verified signature.
vjik Sergei Predvoditelev
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Jan 28, 2025
@pavelsavara pavelsavara added this to the 10.0.0 milestone Jan 28, 2025
@pavelsavara pavelsavara self-assigned this Jan 28, 2025
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@pavelsavara pavelsavara changed the title [browser] single threaded diagnosti server [browser] single threaded diagnostic server Jan 28, 2025
@pavelsavara
Copy link
Member Author

@lateralusX please review this first step

# Conflicts:
#	src/native/eventpipe/CMakeLists.txt
Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

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

Second pass on the EP code, mainly code structural comments as well as one idea around ep_rt_thread_create.

Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

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

Native Mono and EventPipe changes LGTM! Thanks!

@pavelsavara
Copy link
Member Author

To be merged after preview snap

@pavelsavara pavelsavara added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 14, 2025
@pavelsavara pavelsavara removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 20, 2025
@pavelsavara pavelsavara merged commit 3f71cde into dotnet:main Feb 20, 2025
161 of 164 checks passed
@pavelsavara pavelsavara deleted the browser_st_ep_step1 branch February 20, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Diagnostics-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants