Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from CAS to Lua(or Javascript) scripts for Redis integration #410

Open
vladimir-bukhtoyarov opened this issue Oct 3, 2023 · 5 comments
Milestone

Comments

@vladimir-bukhtoyarov
Copy link
Collaborator

vladimir-bukhtoyarov commented Oct 3, 2023

Motivation:
In order to increase scalability and latency, because CAS is not scalled for contended keys.

The math problem:
Redis support only legacy 5.1 Lua interpreter without support of 64 bits integer, and only double arifmetic is available. While currently CAS uses Longs provided by JVM. It makes impossible for some scenarios to write unit tests that checks that nothing changed after migration, because double arithmetic is not accurate for some corner cases.

Proposed solutions of math problem:

@vladimir-bukhtoyarov
Copy link
Collaborator Author

Unfortunatelly, I was unable to find any mature library for Lua 5.1 that supports BigIntegers. All publically available solutions like https://github.com/ennorehling/euler/blob/master/BigNum.lua or https://github.com/empyreuma/bigint.lua were failed to pass my tests. So, there is only one way to support Lua - forget about precision.

@vladimir-bukhtoyarov vladimir-bukhtoyarov changed the title Migrate from CAS to Lua scripts for Redis integration Migrate from CAS to Lua(or Javascript) scripts for Redis integration Oct 16, 2023
@vladimir-bukhtoyarov
Copy link
Collaborator Author

Looks that it is better to wait Javascript API to be generally available and instead of hacking with legacy Lua.
https://redis.io/docs/interact/programmability/triggers-and-functions/concepts/javascript_api/

@vladimir-bukhtoyarov
Copy link
Collaborator Author

vladimir-bukhtoyarov commented Oct 17, 2023

A docker container with Javascript support is already available https://hub.docker.com/r/redislabs/redisgears
Javascript API should be merged to main Redis line in version 8.0

@vladimir-bukhtoyarov
Copy link
Collaborator Author

vladimir-bukhtoyarov commented Mar 23, 2024

It worth to consider to try Kotlin-JS instead of writting js code from scratch. In the theory this should allow to reduce the efforts in following points:

  • It is possible to get java code as is and convert to Kotlin with minimum(in theory) fixes.
  • It is possible to reuse already written junit/spock unit tests with minimum generalization.

Some additional thought about trying Kotlin described there #283

@vladimir-bukhtoyarov
Copy link
Collaborator Author

vladimir-bukhtoyarov commented Mar 29, 2024

Also, it needs to try TeamVM, it looks more promising than kotlinjs, because works with bytecode, as result it is not nessesary to copy something into kotlin.

vladimir-bukhtoyarov pushed a commit that referenced this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant