Skip to content

Conversation

@jiefenghuang
Copy link
Contributor

@jiefenghuang jiefenghuang commented Jul 31, 2025

ref: #1271

Plugin Implementation

The plugin interacts with JuiceFS via TCP or Unix Domain Socket (UDS).

Other approaches (e.g. Go native plugin) are not considered at this time due to concerns over platform compatibility, upgrade compatibility, or usability.

Usage

  1. Fork from https://github.com/jiefenghuang/jfs-plugin
  2. implement https://github.com/jiefenghuang/jfs-plugin/blob/main/pkg/server/plugin.go (directly copy the implementation from plugin_test.go for test)
  3. build and run plugin. (go run main.go server tcp://localhost:8080)
  4. JuiceFS format
JFS_PLUGIN_URL=tcp://localhost:8080 ./juicefs format sqlite3://test.db test --bucket=/tmp/jfs-plugin --storage=plugin
  1. JuiceFS mount
JFS_PLUGIN_URL=tcp://localhost:8080 ./juicefs mount sqlite3://test.db /tmp/jfs

Compatibility (Hot‑Reload)

  1. New Plugin vs. Old JuiceFS
    • Launch a new instance of the plugin bound to the new address.
    • Use a new environment variable JFS_PLUGIN_URL to point to the new plugin.
    • Gracefully restart JuiceFS to switch over to the new plugin without downtime.

  2. Old Plugin vs. New JuiceFS
    • Just perform a graceful restart with the new JuiceFS version.

Performance

BenchmarkPlugin/UDS/Put-8 2638 443185 ns/op 369 B/op 14 allocs/op
BenchmarkPlugin/UDS/Get-8 1185 905237 ns/op 4203320 B/op 20 allocs/op
BenchmarkPlugin/UDS/Limits-8 143218 8609 ns/op 296 B/op 11 allocs/op

BenchmarkPlugin/TCP/Put-8 3274 362298 ns/op 366 B/op 14 allocs/op
BenchmarkPlugin/TCP/Get-8 1363 807282 ns/op 4203392 B/op 21 allocs/op
BenchmarkPlugin/TCP/Limits-8 106866 12811 ns/op 296 B/op 11 allocs/op

Ref

projects about go plugin that some might be usable.

Signed-off-by: jiefenghuang <jiefeng@juicedata.io>
Signed-off-by: jiefenghuang <jiefeng@juicedata.io>
@jiefenghuang jiefenghuang requested review from SandyXSD and davies and removed request for SandyXSD and davies September 3, 2025 09:49
@jiefenghuang jiefenghuang marked this pull request as draft September 8, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants