Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Add performance stats API #445

Merged
merged 7 commits into from
Sep 18, 2019
Merged

Add performance stats API #445

merged 7 commits into from
Sep 18, 2019

Conversation

stevenvergenz
Copy link
Contributor

Implements #374

@@ -30,10 +30,15 @@ import { Sync } from './sync';
* Class to handle operational messages with a client.
*/
export class Execution extends Protocol {
public networkStats: NetworkStats;
Copy link
Contributor

@eanders-ms eanders-ms Sep 11, 2019

Choose a reason for hiding this comment

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

This should go on the Connection class, as a peer of ConnectionQuality. #Closed


/** @private */
public beforeSend(message: Message, promise?: ExportedPromise): Message {
const data = new Buffer(JSON.stringify(message, (key, value) => {
Copy link
Contributor

@eanders-ms eanders-ms Sep 11, 2019

Choose a reason for hiding this comment

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

Benefit to putting NetworkStats on Connection: You won't have to double-serialize the message to get the size. #Closed

Copy link
Contributor Author

@stevenvergenz stevenvergenz Sep 17, 2019

Choose a reason for hiding this comment

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

Actually that's not true. The Pipe connection class deals with objects and not serialized data, so it would still have to manually serialize. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

oh you're right. that is more efficient, but annoying in this instance.


In reply to: 325397097 [](ancestors = 325397097)

import filterEmpty from '../utils/filterEmpty';
import validateJsonFieldName from '../utils/validateJsonFieldName';

export interface NetworkStatsFrame {
Copy link
Contributor

@eanders-ms eanders-ms Sep 11, 2019

Choose a reason for hiding this comment

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

interface [](start = 7, length = 9)

For consistency, prefer type over interface. Reserve interface for types that will be implemented by a class. #Closed

.filter(client => client.id !== clientId && client.isJoined())
.forEach(client => client.setAuthoritative(false));
const oldAuthority = this.authoritativeClient;
const newAuthority = this._clientSet[clientId];
Copy link
Contributor

@eanders-ms eanders-ms Sep 18, 2019

Choose a reason for hiding this comment

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

I was hoping this could be handled on pipe.remote. Getting the stats from the authoritative peer is a lot of new code. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing gets serialized or deserialized anywhere but in a WebSocket connection. If we did it in the pipe it would add overhead.


In reply to: 325909690 [](ancestors = 325909690)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed this is better approach than adding overhead in in pipe.remote.


In reply to: 325918122 [](ancestors = 325918122,325909690)

const toOldAuthority = oldAuthority && oldAuthority.conn instanceof EventedConnection
? oldAuthority.conn : null;
if (oldAuthority) {
oldAuthority.setAuthoritative(false);
Copy link
Contributor

@eanders-ms eanders-ms Sep 18, 2019

Choose a reason for hiding this comment

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

You changed the behavior here. We used to send .setAuthoritative(false) to all other clients. You might be introducing a bug here (or exposing one). Safer to keep it the way it was. #Closed

};

/** A collection of network statistics from a certain point in time. */
export interface NetworkStatsReport {
Copy link
Contributor

@eanders-ms eanders-ms Sep 18, 2019

Choose a reason for hiding this comment

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

interface [](start = 7, length = 9)

This should be a type, not an interface. #Closed

* A snapshot of various stats useful for debugging and benchmarking. None of these correlate exactly with
* a particular client's experience, framerate, memory usage, etc., but should be generally indicative.
*/
export interface PerformanceStats {
Copy link
Contributor

@eanders-ms eanders-ms Sep 18, 2019

Choose a reason for hiding this comment

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

interface [](start = 7, length = 9)

Should be a type not an interface #Closed

* that clients are wasting CPU cycles serializing and deserializing messages.
*/
networkMessageCount: [number, number, number];
}
Copy link
Contributor

@eanders-ms eanders-ms Sep 18, 2019

Choose a reason for hiding this comment

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

Needs a semicolon #Closed

@eanders-ms
Copy link
Contributor

eanders-ms commented Sep 18, 2019

Needs a semicolon (or tslint will complain) #Closed


Refers to: packages/sdk/src/connection/networkStats.ts:91 in 4d59891. [](commit_id = 4d59891, deletion_comment = False)

Copy link
Contributor

@eanders-ms eanders-ms left a comment

Choose a reason for hiding this comment

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

:shipit:

@stevenvergenz stevenvergenz merged commit 52880a1 into red Sep 18, 2019
@stevenvergenz stevenvergenz deleted the stvergen/perf-counters branch September 18, 2019 22:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants