Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

NotFoundError performance #739

Closed
ronag opened this issue Feb 27, 2022 · 4 comments
Closed

NotFoundError performance #739

ronag opened this issue Feb 27, 2022 · 4 comments

Comments

@ronag
Copy link

ronag commented Feb 27, 2022

Creating an Error for "NotFound" instead of just returning null has a significant performance overhead. Creating Error objects are expensive.

Could we have a mode flag where we can avoid this?

@ralphtheninja
Copy link
Member

Is this a real issue somewhere?

@vweevers
Copy link
Member

Some time later I want to remove the (IMO usually unhelpful) error and return undefined instead. Per Level/community#76.

@ronag For the short term, I'd say pull requests to make this behavior opt-in are welcome, but it does depend on which modules you're using. You'll also have to touch any implementation of abstract-leveldown that you're using, because levelup merely wraps the errors. If this involves too many modules, I'm reluctant to accept PRs, because I want to wind down the maintenance of these, in favor of abstract-level.

@vweevers
Copy link
Member

Quick and dirty benchmark of error (!undef) vs undefined:

get 1645997866994

@vweevers
Copy link
Member

vweevers commented Nov 8, 2022

Level/abstract-level#49

@vweevers vweevers closed this as completed Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants