Skip to content

Performance Bottleneck | Screenshot Enumeration & WebSocket #115

@GoDjMike

Description

@GoDjMike

Hey!

Thanks for open-sourcing such a novel EFT tool- I use it every time I play 😄


Issue

I play on Streets and Shoreline a lot, taking dozens of screenshots to update my map position on tarkov.dev via remote connect.
The issue is this: the longer a raid goes on, and the more screenshots I take, the worse performance seems to get.

  • each additional screenshot takes longer and longer between screenshot taken >>> map updated pipeline

Performance Profiling

I dug into why exactly this happens, by implementing some performance profiling on an experimental local branch. My north star here was measuring the milliseconds (ms) it took for each stage of the screenshot taken >>> map updated pipeline.

additional debugging & performance profiling details

I was using the built-in DEBUG profiler across a few different metrics:

  • MapUpdate_WebSocketSend to understand the transport cost as part of the overall screenshot taken >>> map updated pipeline
  • ScreenshotParseTime to measure how long (in ms) each screenshot took to parse for coordinate/heading/bearing metadata
  • RaidDegradation_* indicators aka sequential TimeToUpdate cost (in ms) increases growing for every sequential screenshot

Findings

  1. In GameWatcher on every screenshot event, files on disk are being counted via *.png. This operation grows in cost linearly, meaning the operation slows down progressively over the lifecycle of a long raid with lots of screenshots.
  2. With SocketClient.Send the websocket client is being created, started, then disposed for each screenshot event. Even if parsing is fast and payload creation is quick, we're paying the 100ms-400ms "transport" and TLS handshake costs every time, introducing latency.

Both of these are straightforward to fix, and I've successfully fixed them on my local with great results / very noticeable performance boosts. I'd like to issue some PRs for you to consider merging that would resolve issues 1 & 2?

  • screenshot taken >>> map updated latency went from an avg. of ~800ms to ~300ms on Streets
  • ~350ms of the time-save came from the websocket persistence implementation itself

Proposed PRs

1.) Directory Enumeration Fix:

  • remove the *.png pattern / directory enumeration
  • implement a low-cost "in-memory" store of screenshot filenames (for UX/cleanup)

2.) WebSocket Persistence During Raids:

  • maintain a persistent WebSocket connection from raid start to raid end (event-driven)
  • keep existing payload/schema the exact same
  • if network is temporarily lost during a raid, attempt to reconnect and and resume and/or gracefully fail after n attempts
  • pre-connect / lazy-connect upon raid start and disconnect cleanly at raid end

Very open to discussing how to go forward on this!

Cheers,
Mike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions