@@ -63,12 +63,26 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
63
63
return this . watchNonRecursive ( resource , opts ) ;
64
64
}
65
65
66
+ private getRefreshWatchersDelay ( count : number ) : number {
67
+ if ( count > 200 ) {
68
+ // If there are many requests to refresh, start to throttle
69
+ // the refresh to reduce pressure. We see potentially thousands
70
+ // of requests coming in on startup repeatedly so we take it easy.
71
+ return 500 ;
72
+ }
73
+
74
+ // By default, use a short delay to keep watchers updating fast but still
75
+ // with a delay so that we can efficiently deduplicate requests or reuse
76
+ // existing watchers.
77
+ return 0 ;
78
+ }
79
+
66
80
//#region File Watching (universal)
67
81
68
82
private universalWatcher : AbstractUniversalWatcherClient | undefined ;
69
83
70
84
private readonly universalWatchRequests : IUniversalWatchRequest [ ] = [ ] ;
71
- private readonly universalWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( 0 ) ) ;
85
+ private readonly universalWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( this . getRefreshWatchersDelay ( this . universalWatchRequests . length ) ) ) ;
72
86
73
87
private watchUniversal ( resource : URI , opts : IWatchOptions ) : IDisposable {
74
88
const request = this . toWatchRequest ( resource , opts ) ;
@@ -114,12 +128,9 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
114
128
}
115
129
116
130
private refreshUniversalWatchers ( ) : void {
117
-
118
- // Buffer requests for universal watching to decide on right watcher
119
- // that supports potentially watching more than one path at once
120
131
this . universalWatchRequestDelayer . trigger ( ( ) => {
121
132
return this . doRefreshUniversalWatchers ( ) ;
122
- } ) . catch ( error => onUnexpectedError ( error ) ) ;
133
+ } , this . getRefreshWatchersDelay ( this . universalWatchRequests . length ) ) . catch ( error => onUnexpectedError ( error ) ) ;
123
134
}
124
135
125
136
private doRefreshUniversalWatchers ( ) : Promise < void > {
@@ -155,7 +166,7 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
155
166
private nonRecursiveWatcher : AbstractNonRecursiveWatcherClient | undefined ;
156
167
157
168
private readonly nonRecursiveWatchRequests : INonRecursiveWatchRequest [ ] = [ ] ;
158
- private readonly nonRecursiveWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( 0 ) ) ;
169
+ private readonly nonRecursiveWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( this . getRefreshWatchersDelay ( this . nonRecursiveWatchRequests . length ) ) ) ;
159
170
160
171
private watchNonRecursive ( resource : URI , opts : IWatchOptions ) : IDisposable {
161
172
@@ -184,12 +195,9 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
184
195
}
185
196
186
197
private refreshNonRecursiveWatchers ( ) : void {
187
-
188
- // Buffer requests for nonrecursive watching to decide on right watcher
189
- // that supports potentially watching more than one path at once
190
198
this . nonRecursiveWatchRequestDelayer . trigger ( ( ) => {
191
199
return this . doRefreshNonRecursiveWatchers ( ) ;
192
- } ) . catch ( error => onUnexpectedError ( error ) ) ;
200
+ } , this . getRefreshWatchersDelay ( this . nonRecursiveWatchRequests . length ) ) . catch ( error => onUnexpectedError ( error ) ) ;
193
201
}
194
202
195
203
private doRefreshNonRecursiveWatchers ( ) : Promise < void > {
0 commit comments