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

Mixed chart query optimisation #1690

Merged
merged 11 commits into from
Apr 3, 2020
Merged

Mixed chart query optimisation #1690

merged 11 commits into from
Apr 3, 2020

Conversation

ademuanthony
Copy link
Contributor

Fix #1689

This PR adds a height constraint to the query that fetches vouts for computing anonymity set.

@chappjc
Copy link
Member

chappjc commented Feb 11, 2020

Thanks for the quick response on this @ademuanthony! I'm glad you see the issue, and I appreciate your follow-through. Your mix charts work has been very good.

Just a bit more code formatting to make CI happy.

Note that prior to merging the fix, I'll have to instrument a few functions to provide timing data. It would be helpful if you could do the same and provide before and after values.

@ademuanthony
Copy link
Contributor Author

Thanks for the quick response on this @ademuanthony! I'm glad you see the issue, and I appreciate your follow-through. Your mix charts work has been very good.

Just a bit more code formatting to make CI happy.

Note that prior to merging the fix, I'll have to instrument a few functions to provide timing data. It would be helpful if you could do the same and provide before and after values.

This is the information from the planentdecred dev server
Before:
retrieveAnonymitySet: 28.039550932s
appendAnonymitySet: 1.154520337s

After:
retrieveAnonymitySet: 25.777803803s
appendAnonymitySet: 67.025679ms

@chappjc
Copy link
Member

chappjc commented Feb 12, 2020

Thanks for the timings. I'm going to look into the query on my end however. 25 second is still to high, by a lot unfortunately.

@ademuanthony
Copy link
Contributor Author

In my new update on this PR, I have changed the process of the anonymity set computation to only fetch data from the database during first load and whenever there is a length mismatch in the chart data. Otherwise, I used the in coming mixed output and their spending notification to maintain the value of the running anonymity set

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

Thank you, and sorry for the extremely long delay.

I have a few items for refactoring that I will follow up on myself since I took forever with this PR:

  • InsertVoutsStmt should ideally not take the block height since it is not stored or used for the query, and maybe should not be calling appendNewVoutsToCharts. (*ChainDB).storeTxns has what it needs (the vouts) if the db row id is substituted for another key for the vout.
  • Instead of using voutDbIds key the _charts.UnspentOutputs map (a field of a type in db/cache), should key the map based on txid:out or other unique identifier.
  • The package-level _charts variable should be avoided if possible. Only a couple fields of it are used too.
  • &sql.Rows{} looks like it could be a problem. What happens with rows.Next() for a zero value Rows?

I'm also still seeing ValidateLengths errors, even after removing the old gob file. e.g.:

[WRN] PSQL: charts.ValidateLengths: dataset at index 2 has mismatched length 437622 != 437621
[WRN] PSQL: charts.ValidateLengths: dataset at index 3 has mismatched length 437622 != 437621
[WRN] PSQL: charts.ValidateLengths: dataset at index 10 has mismatched length 437622 != 437621
[WRN] PSQL: ChartData.Lengthen: block data length mismatch detected. Truncating blocks length to 437621

@chappjc chappjc merged commit 9b8c4f1 into decred:master Apr 3, 2020
@chappjc chappjc mentioned this pull request Apr 8, 2020
@raedah raedah deleted the anonymity-set-improvement branch September 8, 2021 19:26
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

Successfully merging this pull request may close these issues.

mix chart queries need optimization
2 participants