@@ -5,7 +5,7 @@ import { LoggerFactory } from '../telemetry/LoggerFactory';
55import { ScopedTelemetry } from '../telemetry/ScopedTelemetry' ;
66import { Telemetry } from '../telemetry/TelemetryDecorator' ;
77import { isWindows } from '../utils/Environment' ;
8- import { toString } from '../utils/String' ;
8+ import { formatNumber , toString } from '../utils/String' ;
99import { DataStore , DataStoreFactory , StoreName } from './DataStore' ;
1010import { LMDBStore } from './lmdb/LMDBStore' ;
1111import { stats } from './lmdb/Stats' ;
@@ -69,7 +69,7 @@ export class LMDBStoreFactory implements DataStoreFactory {
6969 noSubdir : config . noSubdir ,
7070 overlappingSync : config . overlappingSync ,
7171 } ,
72- `Initialized LMDB ${ Version } with stores: ${ toString ( storeNames ) } ` ,
72+ `Initialized LMDB ${ Version } with stores: ${ toString ( storeNames ) } and ${ formatNumber ( this . totalBytes ( ) / ( 1024 * 1024 ) , 4 ) } MB ` ,
7373 ) ;
7474 }
7575
@@ -110,19 +110,18 @@ export class LMDBStoreFactory implements DataStoreFactory {
110110 }
111111
112112 private emitMetrics ( ) : void {
113- let totalBytes = 0 ;
113+ const totalBytes = this . totalBytes ( ) ;
114+
114115 const envStat = stats ( this . env ) ;
115116 this . telemetry . histogram ( 'version' , VersionNumber ) ;
116117 this . telemetry . histogram ( 'env.size.bytes' , envStat . totalSize , { unit : 'By' } ) ;
117118 this . telemetry . histogram ( 'env.max.size.bytes' , envStat . maxSize , {
118119 unit : 'By' ,
119120 } ) ;
120121 this . telemetry . histogram ( 'env.entries' , envStat . entries ) ;
121- totalBytes += envStat . totalSize ;
122122
123123 for ( const [ name , store ] of this . stores . entries ( ) ) {
124124 const stat = store . stats ( ) ;
125- totalBytes += stat . totalSize ;
126125
127126 this . telemetry . histogram ( `store.${ name } .size.bytes` , stat . totalSize , {
128127 unit : 'By' ,
@@ -137,6 +136,17 @@ export class LMDBStoreFactory implements DataStoreFactory {
137136 unit : 'By' ,
138137 } ) ;
139138 }
139+
140+ private totalBytes ( ) {
141+ let totalBytes = 0 ;
142+ totalBytes += stats ( this . env ) . totalSize ;
143+
144+ for ( const store of this . stores . values ( ) ) {
145+ totalBytes += store . stats ( ) . totalSize ;
146+ }
147+
148+ return totalBytes ;
149+ }
140150}
141151
142152const VersionNumber = 5 ;
0 commit comments