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

clear without limit #30

Closed
ronag opened this issue May 1, 2022 · 8 comments
Closed

clear without limit #30

ronag opened this issue May 1, 2022 · 8 comments

Comments

@ronag
Copy link

ronag commented May 1, 2022

rocksdb has a very nice DeleteRange API which is non blocking and would be great for clear. However, there are two problems:

  • Open end is not supported. (Could be hack emulate with '\fffffffffffffff')
  • Limit is not supported.

Any chance of making these optional in the level API?

@ronag
Copy link
Author

ronag commented May 1, 2022

Optionally if we could add a deleteRange API call and discourage clear.

@vweevers
Copy link
Member

vweevers commented May 1, 2022

Why is DeleteRange better? Especially if it does not support these options?

@ronag
Copy link
Author

ronag commented May 1, 2022

Because it's non blocking. It can apply the delete lazily while applying it to all preceding reads in memory. Also you can do delete range in a batch.

@vweevers
Copy link
Member

vweevers commented May 1, 2022

Not sure I understand what you mean by non blocking.

@ronag
Copy link
Author

ronag commented May 1, 2022

Not sure I understand what you mean by non blocking.

It doesn't block the thread due to IO.

@vweevers
Copy link
Member

vweevers commented May 1, 2022

From the JS side that doesn't matter. Unless your concern is not having enough threads in the async worker pool (for things other than level)?

@ronag
Copy link
Author

ronag commented May 1, 2022

I'm actually trying to do all the write operations in the main js thread due to a few different reasons:

  • Avoid overhead of marshalling data to the thread pool.
  • Increase consistency with reads, i.e. writes are immediately visible for preceding read calls. Without having to add a lot of complicated write barriers and read queuing in the binding. (Snapshots caveats classic-level#28)
  • Avoid problems with writes being applied out of order due to thread pool scheduling. (Are writes ordered? classic-level#29)
  • Range deletes can be done in a batch.

In rocksdb and I believe also leveldb writes are non blocking as long as the writing background threads can keep up.

@vweevers
Copy link
Member

vweevers commented Oct 1, 2022

Not sure if there's anything left to answer here. I'll address some specific points:

Open end is not supported

That simply makes it incompatible with the abstract-level API. Unlike limit, the use cases for ltgt options are (I hope) obvious and these options are a core part of level. So can't make this an optional feature.

Limit is not supported

See #38 (comment) - which was a duplicate issue?

Optionally if we could add a deleteRange API call and discourage clear.

I don't want to add RocksDB-specific features that are a limited subset of existing functionality. Your implementation is free to have additional methods ofc (like deleteRange). Perhaps a better way forward is to not follow the abstract-level interface at all, if the requirements are too different.

Increase consistency with reads, i.e. writes are immediately visible for preceding read calls. Without having to add a lot of complicated write barriers and read queuing in the binding.

You have a fundamentally different idea of what the order of operations should be. Which is fine, but it's not level. Level promises consistency in a simple way: want to know that a write finished? Await it. Subsequent reads are then guaranteed to include that written data.

Avoid problems with writes being applied out of order due to thread pool scheduling.

Same applies here: userland code can decide (to care about) the order, by awaiting.

@vweevers vweevers closed this as completed Oct 1, 2022
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

No branches or pull requests

2 participants