Details
-
Wish
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.8.1
Description
In the SyncRequestProcessor, a write operation is performed for each write request. Two methods are relatively time-consuming.
1. Within SyncRequestProcessor#shouldSnapshot, the current size of the current file is retrieved, which involves a system call.
Call stack:
java.io.File.length(File.java)
org.apache.zookeeper.server.persistence.FileTxnLog.getCurrentLogSize(FileTxnLog.java:211)
org.apache.zookeeper.server.persistence.FileTxnLog.getTotalLogSize(FileTxnLog.java:221)
org.apache.zookeeper.server.persistence.FileTxnSnapLog.getTotalLogSize(FileTxnSnapLog.java:671)
org.apache.zookeeper.server.ZKDatabase.getTxnSize(ZKDatabase.java:790)
org.apache.zookeeper.server.SyncRequestProcessor.shouldSnapshot(SyncRequestProcessor.java:145)
org.apache.zookeeper.server.SyncRequestProcessor.run(SyncRequestProcessor.java:182)
2. Within ZKDatabase#append, the current position of the current file is retrieved, which also involves a system call.
Call stack:
sun.nio.ch.FileDispatcherImpl.seek(FileDispatcherImpl.java)
sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:264)
org.apache.zookeeper.server.persistence.FilePadding.padFile(FilePadding.java:76)
org.apache.zookeeper.server.persistence.FileTxnLog.append(FileTxnLog.java:298)
org.apache.zookeeper.server.persistence.FileTxnSnapLog.append(FileTxnSnapLog.java:592)
org.apache.zookeeper.server.ZKDatabase.append(ZKDatabase.java:678)
org.apache.zookeeper.server.SyncRequestProcessor.run(SyncRequestProcessor.java:181)
Therefore, it is best to maintain the current size and position of the current file ourselves, as this can greatly improve performance.
Attachments
Attachments
Issue Links
- requires
-
ZOOKEEPER-4715 Verify file size and position in testGetCurrentLogSize.
- Closed
- links to