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

tapdb: fix performance of aggregate stats #1310

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

guggero
Copy link
Member

@guggero guggero commented Jan 20, 2025

Addition to #1302.

Difference can best be seen when running make unit-trace pkg=tapdb long-tests=1 case=TestUniverseIndexPerformance/name=query_aggregated:

    universe_perf_test.go:279: No indices exec time: 28.961577804s
    universe_perf_test.go:280: With indices exec time: 11.647093789s
    universe_perf_test.go:289: Improvement: 2.49x

I also confirmed on mainnet that the old and new query return the exact same result:
old-query.txt
new-query.txt

The speedup on mainnet is also quite significant. The old query took 2.5 minutes while the new one only took 15 seconds.

Hopefully this should make #1302 not necessary (but let's keep it anyway, since it's a good idea as well).

Shout out to @jbrill who's performance test setup allowed me to test this quite easily.

This commit cleans up and fixes a couple of things in the universe index
performance test:
1. More compact formatting for some of the queries.
2. Update index name, was incorrect before.
3. Add context to where the individual queries come from.
4. Allow specific sub tests to be run.
@guggero guggero force-pushed the aggregate-stats-performance branch from eac021b to fa0d45b Compare January 20, 2025 16:09
@coveralls
Copy link

coveralls commented Jan 20, 2025

Pull Request Test Coverage Report for Build 12871932746

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 23 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.01%) to 40.768%

Files with Coverage Reduction New Missed Lines %
tappsbt/create.go 2 53.22%
commitment/tap.go 3 84.09%
asset/asset.go 4 76.9%
tapdb/multiverse.go 6 68.21%
tapgarden/caretaker.go 8 68.5%
Totals Coverage Status
Change from base Build 12871624285: 0.01%
Covered Lines: 26658
Relevant Lines: 65390

💛 - Coveralls

Copy link
Contributor

@jbrill jbrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! Huge optimization 👏 just added a few comments/questions

@@ -0,0 +1,2 @@
-- This file is empty on purpose. There is nothing to roll back for this
-- migration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to restore the old universe_view in this rollback?

FROM aggregated ag
JOIN universe_roots roots
ON ag.universe_root_id = roots.id
GROUP BY roots.asset_id, roots.group_key, roots.proof_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not tweak the index here like in the test?

		CREATE INDEX IF NOT EXISTS idx_universe_leaves_asset
		ON universe_leaves(
			asset_genesis_id, universe_root_id
		);`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with idx_mssmt_nodes_composite

numQueries = 100 * longTestScale
numAssets = 100 * longTestScale
numLeavesPerTree = 300 * longTestScale
numQueries = 100 * longTestScale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the test timeout be a bit longer for the _long_test.go or do you think the 5 minute timeout is ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

3 participants