@@ -13,7 +13,7 @@ import * as env from 'lib0/environment'
13
13
import * as logging from 'lib0/logging'
14
14
15
15
const logWorker = logging . createModuleLogger ( '@y/redis/api/worker' )
16
- // const logApi = logging.createModuleLogger('@y/redis/api')
16
+ const logApi = logging . createModuleLogger ( '@y/redis/api' )
17
17
18
18
let ydocUpdateCallback = env . getConf ( 'ydoc-update-callback' )
19
19
if ( ydocUpdateCallback != null && ydocUpdateCallback . slice ( - 1 ) !== '/' ) {
@@ -226,10 +226,12 @@ export class Api {
226
226
async getDoc ( room , docid ) {
227
227
const ms = extractMessagesFromStreamReply ( await this . redis . xRead ( redis . commandOptions ( { returnBuffers : true } ) , { key : computeRedisRoomStreamName ( room , docid , this . prefix ) , id : '0' } ) , this . prefix )
228
228
const docMessages = ms . get ( room ) ?. get ( docid ) || null
229
+ if ( docMessages ?. messages ) logApi ( `processing messages of length: ${ docMessages ?. messages . length } in room: ${ room } ` )
229
230
const docstate = await this . store . retrieveDoc ( room , docid )
230
231
const ydoc = new Y . Doc ( )
231
232
const awareness = new awarenessProtocol . Awareness ( ydoc )
232
233
awareness . setLocalState ( null ) // we don't want to propagate awareness state
234
+ const now = performance . now ( )
233
235
ydoc . transact ( ( ) => {
234
236
if ( docstate ) { Y . applyUpdateV2 ( ydoc , docstate . doc ) }
235
237
docMessages ?. messages . forEach ( m => {
@@ -248,6 +250,7 @@ export class Api {
248
250
}
249
251
} )
250
252
} )
253
+ logApi ( `took ${ performance . now ( ) - now } ms to process messages for room: ${ room } ` )
251
254
return { ydoc, awareness, redisLastId : docMessages ?. lastId . toString ( ) || '0' , storeReferences : docstate ?. references || null }
252
255
}
253
256
0 commit comments