Refactor: use rust for native mastodon id conversion #9786

Merged
thatonecalculator merged 11 commits from s1idewhist1e/calckey:refactor/mastodon-id-conversion into develop 2 months ago
Collaborator

This uses napi-rs to allow for automatic generation of node bindings for the native code.

I also changed the isolatedModules TS flag to false to allow for static enum to be shared across modules. It doesn't seem to be necessary for the build system that CK uses.

Currently this method does not work with ID generators with longer IDs. Likely the best solution is to add another key in the database.

Some benchmarks for 1 million conversions:

	node, x1_000_000: 2.847s
	rust, x1_000_000: 1.265s

There are still optimizations that can be made, but I think this is a good starting point and a good way to bring rust into the CK stack.

This uses [napi-rs](https://napi.rs/) to allow for automatic generation of node bindings for the native code. I also changed the `isolatedModules` TS flag to false to allow for `static enum` to be shared across modules. It doesn't seem to be necessary for the build system that CK uses. Currently this method does not work with ID generators with longer IDs. Likely the best solution is to add another key in the database. Some benchmarks for 1 million conversions: ``` node, x1_000_000: 2.847s rust, x1_000_000: 1.265s ``` There are still optimizations that can be made, but I think this is a good starting point and a good way to bring rust into the CK stack.
s1idewhist1e added 10 commits 2 months ago
s1idewhist1e added 1 commit 2 months ago
thatonecalculator merged commit c58ce6c53b into develop 2 months ago

Do we need to install cargo for this?

Do we need to install cargo for this? ![](https://cdn.discordapp.com/attachments/823878222897741868/1091226108466307132/2023-03-31_140236.png)

I'm sorry I overlooked the README change!!
Never mind my previous comment. Great job! 🦀

I'm sorry I overlooked the README change!! Never mind my previous comment. Great job! 🦀
The pull request has been merged as c58ce6c53b.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b s1idewhist1e-refactor/mastodon-id-conversion develop
git pull refactor/mastodon-id-conversion

Step 2:

Merge the changes and update on Forgejo.
git checkout develop
git merge --no-ff s1idewhist1e-refactor/mastodon-id-conversion
git push origin develop
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: calckey/calckey#9786
Loading…
There is no content yet.