Adaptive frontend performance diagnosis and remediation
In telemetry data received from telemetry code in a frontend code executing on a user device, an anomaly is detected corresponding to a performance metric of the frontend code. The anomaly is mapped to a portion of the frontend code as a root-cause of the anomaly. A code patch is generated; the code patch being configured to avoid the anomaly. In a memory of the user device, the frontend code is modified with the code patch, the modifying causing the modified frontend code to be rendered on the user device.
1 . A computer-implemented method, comprising:
executing telemetry code on a user device, in a context of a frontend code of an application on the user device, to send telemetry data to a telemetry buffer;
detecting, in the telemetry data received from telemetry code in a frontend code executing on a user device, an anomaly corresponding to a performance metric of the frontend code, wherein the detecting is performed by a Long Short-Term Memory (LSTM) autoencoder model configured to identify a sequential anomaly in a time-series of the telemetry data using a statistical baseline;
mapping the anomaly to a portion of the frontend code as a root-cause of the anomaly;
generating a code patch, the code patch configured to avoid the anomaly;
modifying, in a memory of the user device, the frontend code with the code patch, the modifying causing the modified frontend code to be rendered on the user device;
wherein passing sequences of feature vectors by composing of timing, memory and rendering telemetry data into the LSTM autoencoder which reconstructs each sequence of the feature vectors and returns an anomaly score and metric values exceeding a tunable threshold identify temporal anomalies; and
wherein the telemetry data collected by capturing real-time rendering metrics, memory usage and network latency data, and the real-time rendering metrics, the memory usage, the network latency and other similar metrics are accumulated in the telemetry buffer and streamed to monitoring components via a protocol.
2 . The computer-implemented method of claim 1 , further comprising:
constructing a statistical baseline of a frontend behavior from a training dataset comprising previous frontend performance data; and
determining as a part of the detecting, by comparing a datum in the telemetry data to the statistical baseline, that the telemetry data comprises the anomaly.
3 . The computer-implemented method of claim 1 , further comprising:
training a Machine Learning (ML) model, using a training dataset comprising previous frontend performance data, to identify anomalous frontend behavior;
inputting into the trained ML model the telemetry data; and
outputting from the trained ML model, as a part of the detecting, an indication that the telemetry data comprises the anomaly.
4 . The computer-implemented method of claim 1 , further comprising:
injecting at the user device, in real-time and subsequent to the frontend code of an application being delivered to the user device for rendering, the telemetry code into the frontend code;
collecting, at the user device, the telemetry data from the telemetry code; and
transmitting the telemetry data as a time-series.
5 . The computer-implemented method of claim 1 , further comprising:
constructing a statistical baseline using from historical telemetry data from a past user session, wherein the baseline corresponds to the performance metric, and wherein the performance metric corresponds to at least one of (i) First Contentful Paint (FCP), (ii) Largest Contentful Paint (LCP), (iii) Cumulative Layout Shift (CLS), (iv) Time to Interactive (TTI), (v) Frames Per Second (FPS), (vi) memory usage, and (vii) Application Programming Interface (API) latency.
6 . The computer-implemented method of claim 1 , wherein the detecting the anomaly further comprises at least one of smoothing a short-term fluctuation in the telemetry data, eliminating an outlier data point in the telemetry data based on a deviation from mean, identifying a seasonality in the telemetry data, and identifying a trend in the telemetry data.
7 . The computer-implemented method of claim 1 , further comprising:
inputting, the telemetry data into the LSTM autoencoder model; and
outputting from the LSTM autoencoder model, as a part of the detecting the anomaly, the sequential anomaly in a time-series of the telemetry data.
8 . The computer-implemented method of claim 7 , wherein the LSTM autoencoder model has been pretrained using synthetic telemetry trace data indicative of a simulated frontend code behavior.
9 . The computer-implemented method of claim 7 , wherein the detecting comprises:
causing the LSTM autoencoder model to assign a score to the anomaly; and
passing the anomaly to a root-cause mapping tooling to perform the mapping responsive to the score exceeding a threshold.
10 . The computer-implemented method of claim 1 , wherein the mapping comprises:
matching a first timestamp of the anomaly with a second timestamp of an event recorded in a stack trace of a runtime call stack corresponding to the frontend code; and
correlating the portion of the frontend code as the root-cause of the anomaly responsive to the first timestamp being within a threshold period of the second timestamp, and the event being related to an execution of the portion of the frontend code.
11 . The computer-implemented method of claim 1 , wherein the mapping comprises:
matching a first timestamp of the anomaly with a second timestamp of a lifecycle event of a code component in the frontend code; and
correlating the portion of the frontend code as the root-cause of the anomaly responsive to the first timestamp being within a threshold period of the second timestamp, and the code component being related to the portion of the frontend code.
12 . The computer-implemented method of claim 1 , further comprising:
detecting, in a second telemetry data received from the telemetry code a change in the performance metric;
generating labeled data for a retraining dataset using the anomaly, the code patch, and the change; and
retraining a model used in identifying the anomaly using the labeled data.
13 . The computer-implemented method of claim 1 , further comprising:
detecting, in a second telemetry data received from the telemetry code a change in the performance metric;
generating labeled data for a retraining dataset using the anomaly, the code patch, and the change; and
retraining a model used in generating the code patch using the labeled data.
14 . The computer-implemented method of claim 1 , further comprising:
reviewing the code patch for deployment, wherein the modifying is responsive to the reviewing resulting in an approval.
15 . A computer program product comprising one or more computer readable storage media, and program instructions collectively stored on the one or more computer readable storage media, the program instructions executable by a set of one or more processors to cause the set of one or more processors to perform operations comprising:
executing telemetry code on a user device, in a context of a frontend code of an application on the user device, to send telemetry data to a telemetry buffer;
detecting, in the telemetry data received, an anomaly corresponding to a performance metric of the frontend code, wherein the detecting is performed by a Long Short-Term Memory (LSTM) autoencoder model configured to identify a sequential anomaly in a time-series of the telemetry data using a statistical baseline;
mapping the anomaly to a portion of the frontend code as a root-cause of the anomaly;
generating a code patch, the code patch configured to avoid the anomaly;
modifying, in a memory of the user device, the frontend code with the code patch, the modifying causing the modified frontend code to be rendered on the user device;
wherein passing sequences of feature vectors by composing of timing, memory and rendering telemetry data into the LSTM autoencoder which reconstructs each sequence of the feature vectors and returns an anomaly score and metric values exceeding a tunable threshold identify temporal anomalies; and
wherein the telemetry data collected by capturing real-time rendering metrics, memory usage and network latency data, and the real-time rendering metrics, the memory usage, the network latency and other similar metrics are accumulated in the telemetry buffer and streamed to monitoring components via a protocol.
16 . The computer program product of claim 15 , the operations further comprising:
constructing a statistical baseline of a frontend behavior from a training dataset comprising previous frontend performance data; and
determining as a part of the detecting, by comparing a datum in the telemetry data to the statistical baseline, that the telemetry data comprises the anomaly.
17 . The computer program product of claim 15 , the operations further comprising:
training a Machine Learning (ML) model, using a training dataset comprising previous frontend performance data, to identify anomalous frontend behavior;
inputting into the trained ML model the telemetry data; and
outputting from the trained ML model, as a part of the detecting, an indication that the telemetry data comprises the anomaly.
18 . The computer program product of claim 15 , wherein the stored program instructions are stored in a computer readable storage device in a data processing system, and wherein the stored program instructions are transferred over a network from a remote data processing system.
19 . The computer program product of claim 15 , wherein the stored program instructions are stored in a computer readable storage device in a server data processing system, and wherein the stored program instructions are downloaded in response to a request over a network to a remote data processing system for use in a computer readable storage device associated with the remote data processing system, the operations further comprising:
metering a use of the program instructions associated with the request; and
generating an invoice based on the use.
20 . A computer system comprising a set of one or more processors and one or more computer readable storage media, and program instructions collectively stored on the one or more computer readable storage media, the program instructions executable by the set of one or more processors to cause the processor to perform operations comprising:
executing telemetry code on a user device, in a context of a frontend code of an application on the user device, to send telemetry data to a telemetry buffer;
detecting, in the telemetry data, an anomaly corresponding to a performance metric of the frontend code, wherein the detecting is performed by a Long Short-Term Memory (LSTM) autoencoder model configured to identify a sequential anomaly in a time-series of the telemetry data using a statistical baseline;
mapping the anomaly to a portion of the frontend code as a root-cause of the anomaly;
generating a code patch, the code patch configured to avoid the anomaly;
modifying, in a memory of the user device, the frontend code with the code patch, the modifying causing the modified frontend code to be rendered on the user device;
wherein passing sequences of feature vectors by composing of timing, memory and rendering telemetry data into the LSTM autoencoder which reconstructs each sequence of the feature vectors and returns an anomaly score and metric values exceeding a tunable threshold identify temporal anomalies; and
wherein the telemetry data collected by capturing real-time rendering metrics, memory usage and network latency data, and the real-time rendering metrics, the memory usage, the network latency and other similar metrics are accumulated in the telemetry buffer and streamed to monitoring components via a protocol.