Per-request Latency Detection via Bytecode Instrumentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current computing systems face challenges in identifying and reducing latency sources due to the complexity of workflows, limited resource access for monitoring, and the difficulty in capturing accurate latency data, especially for rare events and suspended execution times.

Innovation Solution

A latency detection system that raises events when a worker thread starts, suspends, resumes, or ends execution, allowing an external system to log timestamps and stack traces, thereby aggregating and filtering latency data across various workflows.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If manual timestamp logging is implemented at specific workflow points, then latency measurement precision is improved, but device complexity and ease of operation deteriorate due to code insertion requirements

Engineering Contradiction:
Improvelatency measurement precisionVSAvoidcode insertion complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system uses self-service by automatically injecting timestamp logging code through bytecode manipulation without requiring manual code insertion. The bytecode agent intercepts workflow execution and automatically adds timing instrumentation, eliminating the need for developers to manually insert timestamp code at various workflow points while maintaining precise latency measurement capability

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The bytecode agent serves as an intermediary between the workflow execution and the timestamp logging mechanism. It intercepts method calls and returns during workflow execution, automatically injecting timing logic without modifying the original workflow code, thus resolving the contradiction between measurement precision and code insertion complexity

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If comprehensive monitoring resources are allocated to track all workflow activities, then latency detection precision is improved, but productivity deteriorates due to resource consumption

Engineering Contradiction:
Improvelatency detection precisionVSAvoidsystem productivity
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The system applies partial action by selectively monitoring only the critical workflow methods and events that contribute most to latency, rather than comprehensively tracking all activities. The bytecode agent focuses on intercepting key entry and exit points in the workflow, providing sufficient latency detection precision while minimizing the overhead on system productivity

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system replaces heavy mechanical monitoring resources with a lightweight bytecode manipulation approach. Instead of allocating dedicated monitoring threads and resources to track all workflow activities, the solution uses bytecode agents that run within the existing JVM infrastructure, substituting resource-intensive monitoring with efficient in-process instrumentation

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

3Ease of operation

If suspended execution time is attributed to workflow latency, then measurement simplicity is improved, but measurement precision deteriorates due to inaccurate latency attribution

Engineering Contradiction:
Improvemeasurement simplicityVSAvoidlatency attribution accuracy
Core Design Contradiction:
Ease of operationVSMeasurement precision

Solution Approach 1:

The system uses feedback by tracking the execution state and suspension status of workflow threads. The bytecode agent monitors whether a thread is actively executing or suspended, and this feedback information is used to correctly attribute timing measurements. When a thread is suspended, the system adjusts the latency calculation to exclude suspended periods, maintaining measurement simplicity while improving attribution accuracy through state-aware feedback

Inventive Principle:
Principle #23Feedback

Data Source

PatentUS10579446B2Per-request event detection to improve request-response latency
Publication Date: 2020.03.03 MICROSOFT TECHNOLOGY LICENSING LLC
  • US10579446B2 patent drawing
  • US10579446B2 patent drawing
  • US10579446B2 patent drawing

AI summary

Events are raised by a worker thread that is executing a workflow, when the worker thread starts, suspends, resumes and ends execution of the workflow. A latency detection system, that is external to the worker thread, detects when these events are raised and logs a timestamp and a stack trace, corresponding to the workflow and the event that was raised.