perf: reduce screenshot encoding time and XML parsing overhead#2
perf: reduce screenshot encoding time and XML parsing overhead#2sanjarcode wants to merge 3 commits into
Conversation
- Scale down screenshots to 0.5x (configurable via SCREENSHOT_SCALE env) before annotation and encoding, cutting pixel count by 75% - Set PNG compress_level=1 in screenshot_in_bytes and as_base64 for 3-5x faster encoding with slightly larger output - Pre-compile bounds regex in tree/utils.py to avoid recompilation on every node during XML tree parsing - Move threading import to module level in mobile/service.py - Remove asyncio.sleep(1) from lifespan to eliminate startup delay Co-authored-by: Sanjar Afaq <sanjarcode@users.noreply.github.com>
|
@claude, can you add some testing instrumentations, at general points (that are also in the master branch). So i can assess performancer changes. Ensure the logs are put into $branch-name.log, and they are git ignored, so I can see them without interference. |
|
Claude finished @sanjarcode's task in 3m 16s —— View job Performance Instrumentation Added
What was addedNew file: Instrumented points (all present in master branch code paths):
Sample log output ( Run the server from the project root and the log file will appear there automatically. Since |
- Add perf_log.py with timed() context manager writing to {branch-name}.log
- Instrument capture_data: dump_hierarchy, screenshot, total parallel time
- Instrument get_state: capture, tree parsing, resize, annotation, encoding
- Instrument get_element_tree, get_interactive_elements, annotated_screenshot
- Add *.log to .gitignore so log files are not tracked
Co-authored-by: Sanjar Afaq <sanjarcode@users.noreply.github.com>
Fixes performance issues reported in #1
Generated with Claude Code
#1