Skip to content

feat: vendor the bigredis swap-prefetch API - #478

Merged
chesedo merged 1 commit into
masterfrom
feature/swap-prefetch-api
Aug 11, 2026
Merged

feat: vendor the bigredis swap-prefetch API#478
chesedo merged 1 commit into
masterfrom
feature/swap-prefetch-api

Conversation

@chesedo

@chesedo chesedo commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Vendors RedisModule_SwapPrefetchKey, RedisModule_IsKeyInRam, the RedisModuleSwapPrefetchCB typedef and the three REDISMODULE_SWAP_PREFETCH_FLAG_* constants, and wires both pointers up in RedisModule_InitAPI.

Together these let a module read a bigredis keyspace without blocking on disk I/O: IsKeyInRam reports whether a key is resident, SwapPrefetchKey schedules a swap-in and fires a callback once it lands. Both are RLEC extensions our vendored header did not carry, even though it already carries the rest of the bigredis block. RediSearchEnterprise hand-declares them downstream today.

Two notes for review:

  • The declarations are copied verbatim from RediSearch's src/redismodule.h and sit in the same position relative to the RedisModule_Big* block, so a future re-vendor diffs cleanly. The declaration order and the reversed REDISMODULE_GET_API order are both upstream's, preserved rather than tidied.
  • build.rs gains one int_macro mapping so the flag constants emit as c_int rather than bindgen's default u32, since they are passed as SwapPrefetchKey's int flags argument. Same arm that already handles REDISMODULE_NOTIFY_*.

No safe wrapper is added — callers reach these through redis_module::raw, as with the rest of the bigredis block.

🤖 Generated with Claude Code

`RedisModule_SwapPrefetchKey` schedules a key to be swapped in from disk and fires a callback once it lands; `RedisModule_IsKeyInRam` reports whether that is needed at all. Together they let a module read a bigredis keyspace without blocking on disk I/O. Both are RLEC extensions, and the vendored `redismodule.h` did not carry them even though it already carries the rest of the bigredis block.

Copy the declarations verbatim from RediSearch's header and keep them in the same position relative to the `RedisModule_Big*` block, so a future re-vendor diffs cleanly.

The three flag constants are emitted as `c_int` rather than bindgen's default `u32`, since they are passed as `SwapPrefetchKey`'s `int flags` argument. This reuses the arm that already does the same for `REDISMODULE_NOTIFY_*`.

Callers reach these through `redis_module::raw`, as they do the rest of the bigredis block; no safe wrapper is added.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chesedo
chesedo merged commit f4d68b9 into master Aug 11, 2026
8 checks passed
@chesedo
chesedo deleted the feature/swap-prefetch-api branch August 11, 2026 07:18
chesedo added a commit to RediSearch/RediSearch that referenced this pull request Aug 11, 2026
Moves the `redis-module` pin onto the current tip of redismodule-rs master. The reason for the bump is RedisLabsModules/redismodule-rs#478, which vendors the bigredis swap-prefetch API — `RedisModule_SwapPrefetchKey`, `RedisModule_IsKeyInRam`, the `RedisModuleSwapPrefetchCB` typedef and the `REDISMODULE_SWAP_PREFETCH_FLAG_*` constants — into that crate's `redismodule.h`, so consumers no longer have to hand-declare them.

RediSearchEnterprise is the consumer that needs this; nothing in this workspace uses the new symbols yet.

The range also picks up #475, which swaps `to_str().unwrap()` for `to_string_lossy()` in `redis_command!` and `redis_event_handler!`. No crate here uses either macro, so it is inert for this workspace.

The rev is duplicated in `workspace_hack/Cargo.toml`, which cargo-hakari generates. No manifest changed upstream between the two revs, so feature unification is unaffected and the update is a pure rev substitution.

RediSearchEnterprise pins the same dependency and the two strings must stay byte-identical. Cargo derives source identity from the literal rev, so abbreviating one side would resolve the same commit through two sources and pull in two copies of the crate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pull Bot pushed a commit to Stars1233/RediSearch that referenced this pull request Aug 11, 2026
build(deps): bump redis-module to f4d68b9

Moves the `redis-module` pin onto the current tip of redismodule-rs master. The reason for the bump is RedisLabsModules/redismodule-rs#478, which vendors the bigredis swap-prefetch API — `RedisModule_SwapPrefetchKey`, `RedisModule_IsKeyInRam`, the `RedisModuleSwapPrefetchCB` typedef and the `REDISMODULE_SWAP_PREFETCH_FLAG_*` constants — into that crate's `redismodule.h`, so consumers no longer have to hand-declare them.

RediSearchEnterprise is the consumer that needs this; nothing in this workspace uses the new symbols yet.

The range also picks up RediSearch#475, which swaps `to_str().unwrap()` for `to_string_lossy()` in `redis_command!` and `redis_event_handler!`. No crate here uses either macro, so it is inert for this workspace.

The rev is duplicated in `workspace_hack/Cargo.toml`, which cargo-hakari generates. No manifest changed upstream between the two revs, so feature unification is unaffected and the update is a pure rev substitution.

RediSearchEnterprise pins the same dependency and the two strings must stay byte-identical. Cargo derives source identity from the literal rev, so abbreviating one side would resolve the same commit through two sources and pull in two copies of the crate.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants