treeshr: pluggable per-scheme backend for tree-file I/O (TreeFileIo)#3062
treeshr: pluggable per-scheme backend for tree-file I/O (TreeFileIo)#3062sammuli wants to merge 1 commit into
Conversation
8cc0508 to
ad9de09
Compare
|
Hi @sammuli -- The next post is not directed to you, but rather to Jenkins. |
|
Retest this please |
|
This will take some time to review, this is a large change and we need to understand exactly how customers will be impacted. We've done extensive experiments with providing a URL-based interface for treeshr, and I'm not sure if this implementation is what we want to include. Truthfully, I believe we should have been included in the planning process for this before an implementation was chosen. |
|
@WhoBrokeTheBuild I'm not at all married to this implementation. It should work ok, but I'm thinking of it as more of a strawman if there are other considerations I'm ignorant of. If there's already a URL-based interface I'm completely open to piggybacking on that. Totally happy to defer to your judgement here. |
|
I'm surprised by the 45 failing tests on RHEL8 x86-64, so I am launching a second build just to see if there was a glitch with Jenkins. |
|
Retest this please |
Add an extension point so the local tree-file I/O path can be served by a pluggable backend selected by URL scheme, instead of always calling the raw open/read/write/lseek/close syscalls. This lets out-of-tree transports (e.g. trees served over HTTP or from an object store) be provided as separate loadable libraries with no new dependency in MDSplus core. It mirrors the existing mdsip transport-plugin pattern (IoRoutines / LoadIo in mdstcpip): mdsip loads MdsIp<PROTOCOL> and calls its "Io" symbol; this loads MdsTreeFile<SCHEME> and calls its "FileIo" symbol. - New TreeFileIo vtable (treeshr/treefileio.h): open/close/read/write/lseek/ lock plus an mmap_capable flag. - GetTreeFileIo() returns a built-in default backend (thin syscall wrappers) for paths with no scheme, otherwise resolves MdsTreeFile<SCHEME> via LibFindImageSymbol_C, caches per scheme (dlopen outside the cache lock), and fails closed on an unknown/unloadable scheme. - fdinfo_t carries the resolved backend; every local MDS_IO_* op dispatches through it. With no scheme present, behavior is byte-for-byte unchanged. - MapFile keys its mmap-vs-buffered choice off the backend's mmap_capable flag (new MDS_IO_MMAP_CAPABLE); non-mmap-able backends use the calloc+read path. Defensive null-outs after free guard against double-free on that path. - Install treefileio.h (the public plugin contract header) so out-of-tree backends can build against an installed MDSplus, and list it in the Debian/RedHat devel package manifests. - Add a dependency-free test (TreeFileIoTest) plus an in-tree reference backend (MdsTreeFileTESTMEM, scheme "testmem://") covering scheme dispatch, per-scheme caching, short-read/EOF semantics, fail-closed, and the mmap_capable plumbing.
ad9de09 to
a8a851f
Compare
|
Heads-up on the commit churn: I pushed one small follow-up ( |
|
Retest this please |
|
Retest this please (only works for developers) |
|
Hi @sammuli -- The second build also failed 45 tests on RHEL8 x86-64. A spot check of a few errors indicates that the tests are not loading This is an excerpt from the logs for test 86. Because these tests are only failing on RHEL8, there is a chance that the problem is with our test environment for that platform. I will investigate that on Tuesday. |
|
Hi @sammuli -- Thanks for committing the manifest changes. The most recent build no longer fails on the "Packaging" steps. However, RHEL8 still has problems because of the |
|
The RHEL8 Docker's image now has three versions of Python: 2.7, 3.11 and 3.12. If running Python3.11, the A conjecture is that the Dockerfile that builds the RHEL8 image recently changed to now also install the Python3.12 version. Jenkins is apparently using Python3.12, which is why the RHEL8 builds fail on both Jenkins and a developer workstation. Further investigation is needed to identify the root cause of the missing NumPy. |
|
This PR did not cause the NumPy problems on RHEL8. It is just coincidence that the RHEL8 container's configuration changed around the same time this PR was submitted. |
|
Jenkins has just been fixed, so rebuilding this PR. |
|
Retest this please |
1 similar comment
|
Retest this please |
Summary
This adds a small extension point so the local tree-file I/O path in
treeshrcan be served by a pluggable backend selected by URL scheme, instead of always
calling the raw
open/read/write/lseek/closesyscalls. It letsout-of-tree transports (e.g. trees served from an HTTP endpoint or an object
store) be provided as separate loadable libraries with no new dependency
in MDSplus core.
The design intentionally mirrors the existing mdsip transport-plugin pattern
(
IoRoutines/LoadIoinmdstcpip/): where mdsip loadsMdsIp<PROTOCOL>andcalls its exported
Iosymbol, this loadsMdsTreeFile<SCHEME>and calls itsexported
FileIosymbol.How it works
TreeFileIo(treeshr/treefileio.h), groups the operations theMDS_IO_*layer performs on a local fd:open/close/read/write/lseek/lockplus an
mmap_capableflag.GetTreeFileIo(filename)inRemoteAccess.c:as today) when the path has no
scheme://prefix;MdsTreeFile<SCHEME>viaLibFindImageSymbol_C, cachesthe result per scheme, and fails closed (open fails) on an unknown or
unloadable scheme rather than treating
"scheme://…"as a literal path.fdinfo_tcarries the resolved backend, and every local-branchMDS_IO_*operation dispatches through it.
MapFilekeys its mmap-vs-buffered decision off the backend'smmap_capableflag (new
MDS_IO_MMAP_CAPABLE): non-mmap-able backends take thecalloc+readpath while ordinary local files keep usingmmap. Defensivenull-outs after
freeinclose_top_tree/MapFileguard against double-freeon the buffered path.
Behavior preservation
With no URL scheme present, the code path is the default backend, i.e.
byte-for-byte the current syscall behavior — no functional change for existing
trees, and no new build/link dependency. The mdsip remote (
conid >= 0) pathis untouched.
Tests
Adds
treeshr/testing/TreeFileIoTest.c, a dependency-free test, andtreeshr/testing/MdsTreeFileTESTMEM.c, a tiny in-tree reference backend(scheme
testmem://) loaded the same way a real backend would be. It covers:default-path round-trip, scheme dispatch + per-scheme cache reuse,
short-read/EOF semantics, fail-closed on an unknown scheme, and the
mmap_capableplumbing.Built with CMake against this branch and run via
ctest; the fulltreeshr/testingsuite passes:Writing a backend
A backend for scheme
x://is a shared librarylibMdsTreeFileX(schemeuppercased) exporting
const TreeFileIo *FileIo(void)with default symbolvisibility. It is discovered lazily on first open of an
x://path. The contractis documented in
treeshr/treefileio.h.Notes for reviewers
MdsTreeFile<SCHEME>) and symbol (FileIo) conventions mirrorthe
MdsIp<PROTOCOL>/Ioprecedent but are of course open to bikeshedding.__declspec(dllexport)for Windows; the in-treereference backend and tests have only been exercised on Linux so far.
treefileio.his currently an internaltreeshrheader (not installed); if youwant third-party backends to build against an installed SDK, it can be added to
the install set.
Addendum by @mwinkel-dev
This PR is related to the Fusion Data Project (FDP) that @sammuli is leading.