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

Compatibility with recent typescript changes #13

Closed
mindreframer opened this issue Jun 4, 2023 · 4 comments
Closed

Compatibility with recent typescript changes #13

mindreframer opened this issue Jun 4, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@mindreframer
Copy link

I have following issues when using blinkdb with bun.sh

$ bun run index.ts
SyntaxError: Indirectly exported binding name 'Ids' is not found.

The fix is to export Ids as from db/remove.ts as type, like here:

export { clear } from "./clear";
export { count } from "./count";
export * from "./createDB";
export * from "./createTable";
export * from "./errors";
export { first } from "./first";
export { insert } from "./insert";
export type { Create } from "./insert";
export { insertMany } from "./insertMany";
export { many } from "./many";
export { one } from "./one";
export { remove } from "./remove";
export type { Ids } from "./remove";
export { removeMany } from "./removeMany";
export { removeWhere } from "./removeWhere";
export { update } from "./update";
export type { Diff } from "./update";
export { updateMany } from "./updateMany";
export { updateWhere } from "./updateWhere";
export { upsert } from "./upsert";
export { upsertMany } from "./upsertMany";
export * from "./use";
export * from "./uuid";
export * from "./watch";

The other issue is with BTree, that I have posted here:

Not sure, if it's would require code changes in Blinkdb to make it work with bun.sh.

@froehlichA
Copy link
Contributor

The type issues are not specific to Bun, types used in exported BlinkDB methods should be exported as well. Oversight on my part.

I'll try and see if I can resolve the BTree issue.

@froehlichA
Copy link
Contributor

froehlichA commented Jun 4, 2023

Found the cause. BlinkDB uses a "module" key as per the module resolution proposal here, which causes Bun to resolve the module differently. Since the JS Ecosystem has apparently never accepted the proposal above and instead moved on to package exports instead, I've removed the module key & will implement the export system as needed.

(And apparently BlinkDB types like Ids, Diff & Create are already exported: https://github.com/blinkdb-js/blinkdb/blob/main/packages/db/src/core/index.ts)


I've pushed up a new version of BlinkDB that fixes these issues, and which works for your repository on my local machine. Can you verify on your end?

@froehlichA froehlichA added the bug Something isn't working label Jun 4, 2023
@mindreframer
Copy link
Author

@froehlichA It works! Thanks for the super-quick response.

I will play with BlinkDB a bit more, it's a really well-structured codebase! Any plans to make the insertMany / updateMany functions faster?

This is what I get in benchmarks:

blinkdb/insert-many.ts --- lokijs is 417.44x faster than blinkdb
┌─────────┬───────────┬────────────────────┬────────────────────┬──────────┬─────────┐
│ (index) │   name    │      ops/sec       │ Average Time (ns)  │  Margin  │ Samples │
├─────────┼───────────┼────────────────────┼────────────────────┼──────────┼─────────┤
│    0    │ 'lokijs'  │ 203398.47530091717 │ 4916.457699697863  │ '±1.64%' │ 101700  │
│    1    │ 'blinkdb' │ 487.25611966443955 │ 2052308.7543542264 │ '±4.94%' │   244   │
└─────────┴───────────┴────────────────────┴────────────────────┴──────────┴─────────┘


blinkdb/upsert-many.ts --- lokijs is 3.87x faster than blinkdb
┌─────────┬───────────┬────────────────────┬────────────────────┬──────────┬─────────┐
│ (index) │   name    │      ops/sec       │ Average Time (ns)  │  Margin  │ Samples │
├─────────┼───────────┼────────────────────┼────────────────────┼──────────┼─────────┤
│    0    │ 'lokijs'  │ 1633.0642639853138 │ 612345.7735579922  │ '±4.32%' │   817   │
│    1    │ 'blinkdb' │ 421.87318580370237 │ 2370380.5637585605 │ '±7.20%' │   211   │
└─────────┴───────────┴────────────────────┴────────────────────┴──────────┴─────────┘


blinkdb/update.ts --- lokijs is 3.34x faster than blinkdb
┌─────────┬───────────┬────────────────────┬────────────────────┬───────────┬─────────┐
│ (index) │   name    │      ops/sec       │ Average Time (ns)  │  Margin   │ Samples │
├─────────┼───────────┼────────────────────┼────────────────────┼───────────┼─────────┤
│    0    │ 'lokijs'  │ 268725.01220459485 │ 3721.2762287964697 │ '±4.79%'  │ 134364  │
│    1    │ 'blinkdb' │ 80449.77230128765  │ 12430.115976648878 │ '±20.82%' │  40354  │
└─────────┴───────────┴────────────────────┴────────────────────┴───────────┴─────────┘

The difference for inserts is quite unusual. And since we need to restore the application state on bootstrap, this might increase the app loading time significantly. But I would need to play with some realistic datasets before making further conclusions.

Anyways, thanks again for the quick fix and have a great Sunday!

@froehlichA
Copy link
Contributor

Thanks for bringing the issue with bun to my attention in the first place :)

insertMany is weird. I expect it to be slower than inserting into an array, since blinkDB is optimized for reads, but not that slow. I'll create a new issue & take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants