pkuwm opened a new issue #1338:
URL: https://github.com/apache/helix/issues/1338
isPrefetchEnabled() is kind of a heavy call as it is using java reflection.
For each subscribeDataChanges(), isPrefetchEnabled() is called every time,
which is unnecessary as the listener has been subscribed before and we actually
could use the listener field to fetch the value isPrefetchEnabled.
So for the same listener, isPrefetchEnabled() is supposed to be called one
time. This avoids duplicate heavy call of isPrefetchEnabled(). Thus improves
performance, as there are too many listener subscriptions.
```
public boolean subscribeDataChanges(String path, IZkDataListener listener,
boolean skipWatchingNonExistNode) {
Set<IZkDataListenerEntry> listenerEntries;
synchronized (_dataListener) {
listenerEntries = _dataListener.get(path);
if (listenerEntries == null) {
listenerEntries = new CopyOnWriteArraySet<>();
_dataListener.put(path, listenerEntries);
}
boolean prefetchEnabled = isPrefetchEnabled(listener);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]