hansva opened a new issue, #9472:
URL: https://github.com/apache/hop/issues/9472

   ### What needs to happen?
   
   The *Check if file is locked* transform and the *Check if files are locked* 
action both use `LockFile` (`plugins/actions/checkfilelocked`). To test a file, 
`LockFile` renames it onto itself. For that it resolves the same name twice 
with `HopVfs.getFileObject`:
   
   ```java
   file = HopVfs.getFileObject(filename, variables);
   if (file.exists()) {
     dummyfile = HopVfs.getFileObject(filename, variables);
     file.moveTo(dummyfile);
   }
   ```
   
   Both calls return the same cached `FileObject`, so the second resolve adds 
cost and nothing else. Resolving a name is about half of the CPU time of the 
transform.
   
   Two smaller things in the same code:
   
   - The `finally` block closes `file` twice. The second close was meant for 
`dummyfile`.
   - With *Add filename to result* on, the transform (`FileLocked.processRow`) 
resolves the name a third time to build the `ResultFile`.
   
   ### Proposed change
   
   - Resolve the name once and move the file onto itself (`file.moveTo(file)`), 
in a try-with-resources block.
   - No change to what counts as locked.
   
   ### Expected gain
   
   Timed on the lock check alone, 100,000 small local files, in the 
`apache/hop:Development` container (Linux, JDK 21), six rounds:
   
   | | files/s |
   |---|---|
   | current (two resolves) | 60,000 to 72,000 |
   | one resolve | 90,000 to 104,000 |
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: Transforms


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to