Skip to content

Commit 9c05b62

Browse files
committed
chore: cleanup ws sub v2 logs
1 parent 6fc68f6 commit 9c05b62

File tree

1 file changed

+17
-93
lines changed

1 file changed

+17
-93
lines changed

sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts

Lines changed: 17 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ export class WebSocketDriftClientAccountSubscriberV2
112112

113113
public async subscribe(): Promise<boolean> {
114114
const startTime = performance.now();
115-
console.log(
116-
`[PROFILING] WebSocketDriftClientAccountSubscriberV2.subscribe() started at ${new Date().toISOString()}`
117-
);
118-
119115
if (this.isSubscribed) {
120116
console.log(
121117
`[PROFILING] WebSocketDriftClientAccountSubscriberV2.subscribe() skipped - already subscribed`
@@ -154,13 +150,6 @@ export class WebSocketDriftClientAccountSubscriberV2
154150
]);
155151
const pubkeyEndTime = performance.now();
156152
const pubkeyDuration = pubkeyEndTime - pubkeyStartTime;
157-
console.log(
158-
`[PROFILING] Public key generation completed in ${pubkeyDuration.toFixed(
159-
2
160-
)}ms (${perpMarketAccountPubkeys.length} perp markets, ${
161-
spotMarketAccountPubkeys.length
162-
} spot markets)`
163-
);
164153

165154
// Profile findAllMarketsAndOracles if needed
166155
let findAllMarketsDuration = 0;
@@ -197,23 +186,6 @@ export class WebSocketDriftClientAccountSubscriberV2
197186
`[PROFILING] findAllMarketAndOracles skipped (shouldFindAllMarketsAndOracles=false)`
198187
);
199188
}
200-
201-
// Profile state public key generation
202-
const statePubkeyStartTime = performance.now();
203-
const statePublicKey = await getDriftStateAccountPublicKey(
204-
this.program.programId
205-
);
206-
const statePubkeyEndTime = performance.now();
207-
const statePubkeyDuration = statePubkeyEndTime - statePubkeyStartTime;
208-
console.log(
209-
`[PROFILING] State public key generation completed in ${statePubkeyDuration.toFixed(
210-
2
211-
)}ms`
212-
);
213-
214-
// Profile parallel market and state subscriptions
215-
const parallelSubStartTime = performance.now();
216-
217189
// Create subscribers
218190
this.perpMarketAllAccountsSubscriber =
219191
new WebSocketProgramAccountSubscriberV2<PerpMarketAccount>(
@@ -247,15 +219,6 @@ export class WebSocketDriftClientAccountSubscriberV2
247219
spotMarketAccountPubkeys // because we pass these in, it will monitor these accounts and fetch them right away
248220
);
249221

250-
this.stateAccountSubscriber = new WebSocketAccountSubscriberV2(
251-
'state',
252-
this.program,
253-
statePublicKey,
254-
undefined,
255-
undefined,
256-
this.commitment as Commitment
257-
);
258-
259222
// Run all subscriptions in parallel
260223
await Promise.all([
261224
// Perp market subscription
@@ -303,43 +266,40 @@ export class WebSocketDriftClientAccountSubscriberV2
303266
}
304267
),
305268
// State account subscription
306-
this.stateAccountSubscriber.subscribe((data: StateAccount) => {
307-
this.eventEmitter.emit('stateAccountUpdate', data);
308-
this.eventEmitter.emit('update');
309-
}),
269+
(async () => {
270+
const statePublicKey = await getDriftStateAccountPublicKey(
271+
this.program.programId
272+
);
273+
this.stateAccountSubscriber = new WebSocketAccountSubscriberV2(
274+
'state',
275+
this.program,
276+
statePublicKey,
277+
undefined,
278+
undefined,
279+
this.commitment as Commitment
280+
);
281+
this.stateAccountSubscriber.subscribe((data: StateAccount) => {
282+
this.eventEmitter.emit('stateAccountUpdate', data);
283+
this.eventEmitter.emit('update');
284+
});
285+
})(),
310286
(async () => {
311287
await this.setInitialData();
312288
const subscribeToOraclesStartTime = performance.now();
313289
await this.subscribeToOracles();
314290
const subscribeToOraclesEndTime = performance.now();
315291
const duration =
316292
subscribeToOraclesEndTime - subscribeToOraclesStartTime;
317-
console.log(
318-
`[PROFILING] subscribeToOracles completed in ${duration.toFixed(2)}ms`
319-
);
320293
return duration;
321294
})(),
322295
(async () => {
323296
const stateFetchStartTime = performance.now();
324297
await this.stateAccountSubscriber.fetch();
325298
const stateFetchEndTime = performance.now();
326299
const stateFetchDuration = stateFetchEndTime - stateFetchStartTime;
327-
console.log(
328-
`[PROFILING] State account fetch completed in ${stateFetchDuration.toFixed(
329-
2
330-
)}ms`
331-
);
332300
})(),
333301
]);
334302

335-
const parallelSubEndTime = performance.now();
336-
const parallelSubDuration = parallelSubEndTime - parallelSubStartTime;
337-
console.log(
338-
`[PROFILING] Parallel market and state subscriptions completed in ${parallelSubDuration.toFixed(
339-
2
340-
)}ms`
341-
);
342-
343303
const initialPerpMarketDataFromLatestData = new Map(
344304
Array.from(this.perpMarketAccountLatestData.values()).map((data) => [
345305
data.data.marketIndex,
@@ -357,28 +317,9 @@ export class WebSocketDriftClientAccountSubscriberV2
357317

358318
this.eventEmitter.emit('update');
359319

360-
// Profile handleDelistedMarketOracles
361-
const handleDelistedStartTime = performance.now();
362320
await this.handleDelistedMarketOracles();
363-
const handleDelistedEndTime = performance.now();
364-
const handleDelistedDuration =
365-
handleDelistedEndTime - handleDelistedStartTime;
366-
console.log(
367-
`[PROFILING] handleDelistedMarketOracles completed in ${handleDelistedDuration.toFixed(
368-
2
369-
)}ms`
370-
);
371321

372-
// Profile oracle map setup
373-
const oracleMapStartTime = performance.now();
374322
await Promise.all([this.setPerpOracleMap(), this.setSpotOracleMap()]);
375-
const oracleMapEndTime = performance.now();
376-
const oracleMapDuration = oracleMapEndTime - oracleMapStartTime;
377-
console.log(
378-
`[PROFILING] Oracle map setup completed in ${oracleMapDuration.toFixed(
379-
2
380-
)}ms`
381-
);
382323

383324
this.isSubscribing = false;
384325
this.isSubscribed = true;
@@ -393,23 +334,6 @@ export class WebSocketDriftClientAccountSubscriberV2
393334
2
394335
)}ms`
395336
);
396-
console.log(
397-
`[PROFILING] Breakdown: pubkeys=${pubkeyDuration.toFixed(
398-
2
399-
)}ms, findAllMarkets=${findAllMarketsDuration.toFixed(
400-
2
401-
)}ms, statePubkey=${statePubkeyDuration.toFixed(
402-
2
403-
)}ms, parallelSubscriptions=${parallelSubDuration.toFixed(
404-
2
405-
// )}ms, setInitialData=${setInitialDataDuration.toFixed(
406-
// 2
407-
// )}ms, subscribeToOracles=${subscribeToOraclesDuration.toFixed(
408-
// 2
409-
)}ms, handleDelisted=${handleDelistedDuration.toFixed(
410-
2
411-
)}ms, oracleMap=${oracleMapDuration.toFixed(2)}ms`
412-
);
413337

414338
return true;
415339
}

0 commit comments

Comments
 (0)