Read Linux file attributes through the FFM API - #2926
Conversation
51fda51 to
52c1978
Compare
52c1978 to
777f935
Compare
|
On the long run it would probably make most sense to use FFM under Linux/POSIX only to implement the The existing native implementations to fetch/put file information are intended to be removed via If you complete a FFM based implementation of
Since #2908 is now merged, these errors are now warnings already. Furthermore it's correct that the generated code is not the most compact one. But I think deterministically generated code is better to maintain on the long run, than AI generated one. |
Bulk directory listing needs libfastlinuxfile, which only the x86_64 fragment ships, so the other Linux architectures fall back to one stat per child through libunixfile. Bind opendir, readdir, statx, readlinkat and chmod through the Foreign Function & Memory API instead: statx has a kernel defined layout that is identical on every architecture, so one implementation covers all of them without a compiled artifact. The bindings are generated by jextract using the script added with this change, as on Windows. Only statx is bound by hand, from the generated descriptor and symbol, because it needs captureCallState to read errno, which is what tells a file that is not there from one that cannot be read. The buffers are held per thread and reused, so a listing allocates nothing per entry beyond the resulting FileInfo. Listing 270027 entries takes 439 to 464 ms against 537 to 563 ms, with identical results for every entry. One behaviour differs on purpose: a symbolic link whose target cannot be stated keeps its symlink attribute and link target in a listing. The JNI listing dropped both, while its single file path already reported them, and that attribute is what the recursive link detection of UnifiedTree reads. Set -Declipse.filesystem.useFfm=false to fall back to the native libraries. Assisted-by: multiple AI agents and layers of automated tooling 🤖
777f935 to
c9c2df0
Compare
|
Thanks, I have switched the bindings to jextract. One exception: statx is bound by hand from the generated statx$address() and statx$descriptor(), with Linker.Option.captureCallState("errno") added, since jextract does not emit that option. Without errno every failure looks the same and RefreshLocalVisitor deletes workspace resources whose statx failed with EACCES or EIO. The JNI handler reads errno today, so dropping the distinction would be a regression rather than a new limitation. That is similar to your adjustment in Lines 113-137 of the merged Win32Handler. Since #2925 would change native code, I would rather not have both of us editing PosixHandler and LocalFileNativesManager at the same time: I can follow-up once #2925 is in. |
|
@HannesWell how did you handle the additional warnings from the jextract generated code in your windows implementation? Just reset the quality gate? (How do I do this?) |
Bulk directory listing needs
libfastlinuxfile, which only the x86_64 fragment ships, so aarch64, ppc64le and loongarch64 fall back to onestatper child throughlibunixfile. This bindsopendir,readdir,statx,readlinkatandchmodthrough the Foreign Function & Memory API instead.struct statxhas a kernel defined layout that is identical on every architecture, so one implementation covers all of them with no compiled artifact, and the native fragments lose their reason to exist. The buffers are held per thread and reused, so a listing allocates nothing per entry beyond the resultingFileInfo.The bindings are generated by jextract using the script added with this change, as on Windows in #2908. Only
statxis bound by hand, and only itsMethodHandle: the descriptor and the symbol come from the generated code, withLinker.Option.captureCallStateadded, becauseerrnois what tells a file that is not there from one that cannot be read and jextract does not emit that option. Note for anyone regenerating:--library cmust be omitted, since it emitslibraryLookup("libc.so"), which cannot be opened on glibc where the library islibc.so.6.Listing 270027 entries in 45409 directories takes 439 to 464 ms against 537 to 563 ms for the JNI handler, with identical results for every entry: names, timestamps, lengths, permissions, symbolic links and link targets.
-Declipse.filesystem.useFfm=falsefalls back to the native libraries.One behaviour differs on purpose: a symbolic link whose target cannot be stated, such as a self referencing one, keeps its symlink attribute and link target in a directory listing. The JNI listing dropped both because its conversion returns early on an error, while its single file path already reported them, and that attribute is what the recursive link detection in
UnifiedTreereads.Moving this into
PosixHandlerand leavingfetchFileInfo/putFileInfoto Java NIO, as suggested in review, is left for a follow-up so that it can be sequenced with #2925.