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

Query: Add Caching Database #632

Closed
9 of 10 tasks
fubuloubu opened this issue Apr 4, 2022 · 4 comments · Fixed by #680
Closed
9 of 10 tasks

Query: Add Caching Database #632

fubuloubu opened this issue Apr 4, 2022 · 4 comments · Fixed by #680
Assignees
Labels
category: feature New feature or request size: 8 pieces Extra challenging, requires research, should be broken up

Comments

@fubuloubu
Copy link
Member

fubuloubu commented Apr 4, 2022

Overview

Ape is slow right now. We can speed it up by providing a robust caching layer.

Specification

  • Create first party plugin ape_cache
  • Create a database schema for types that the new query provider works with (e.g. BlockAPI, TransactionAPI)
  • Override the QueryAPI.update_cache method in the new query provider plugin to serialize the query results and store them in a cache database on disk (SQLite or Postgres, should be user configurable)
  • Update the QueryAPI.estimate_query and QueryAPI.perform_query to respond differently if the requested data is already available in the cache db
  • Explore what database migration commands we might need to service the database over time

Acceptance Criteria

  • Caching can be turned off/bypassed and is not a part of the critical path
  • Caching doesn't interrupt the Query Manager
  • Should always announce if functionality can't be provided
  • Should only say functionality can be done if it can completely provided
  • If functionality can be provided, the result should be exactly the same as the default query provider (brute force/default should be the same as cache)

Dependencies

#701

@fubuloubu fubuloubu added the category: feature New feature or request label Apr 4, 2022
@johnson2427
Copy link
Contributor

johnson2427 commented Apr 6, 2022

ape-cache
ape-cache-db

@fubuloubu fubuloubu changed the title Query: Migrate Default Query Provider to use Caching Database Query: Add Caching Database May 9, 2022
@fubuloubu
Copy link
Member Author

Note: do not migrate DefaultQueryProvider

@NotPeopling2day NotPeopling2day added the size: 5 pieces Challenging, not as well defined, may require help from senior eng label May 31, 2022
@PatrickAlphaC
Copy link
Contributor

Just leaving a note here, some framework comparisons:

Running time <framework> -h (or the help equivalent):

time ape -h

real    0m2.962s
user    0m3.106s
sys     0m0.283s

time brownie -h

real    0m2.040s
user    0m0.838s
sys     0m0.213s

time hh --help

real    0m0.954s
user    0m0.974s
sys     0m0.148s

time forge -h

real    0m0.159s
user    0m0.005s
sys     0m0.004s

time truffle -h

real    0m1.713s
user    0m1.698s
sys     0m0.160s

@fubuloubu
Copy link
Member Author

Just leaving a note here, some framework comparisons:

Not quite related to this feature, but yes click is overall a bit slower than what Brownie is using because it comes more "batteries included" out of the box

Eventually, the goal is rewrite a good portion of the library internals as async, and then explore using click's async implementation to help speed things up a lot.

@johnson2427 johnson2427 added size: 8 pieces Extra challenging, requires research, should be broken up and removed size: 5 pieces Challenging, not as well defined, may require help from senior eng labels Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: feature New feature or request size: 8 pieces Extra challenging, requires research, should be broken up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants