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

feat:profiling:state summary and visualization #11012

Merged
merged 12 commits into from
Jul 6, 2023
Merged

Conversation

ZenGround0
Copy link
Contributor

@ZenGround0 ZenGround0 commented Jun 28, 2023

Related Issues

#10884

Proposed Changes

  • One lotus-shed command that takes a non-running repo and generates a summary of data usage by protocol area
  • A python script for visualizing the data

Additional Info

Testplan

I've done many manual runs on calibration and mainnet repos and both lotus-shed and python script generate plausible output. Ive cross checked output data and it appears legit matching lotus chain store size + providing an explanation for pre nv19 snapshot bloat. I think this is good enough for running a monitoring service. If we find problems we can fix them as they show up.

Speed

While reviewing please keep an eye out for optimization opportunities in the shed command, today it takes about 5 hours to run so a 20% improvement is an hour saved.

Halp

@jennijuju where should documentation for this go? I have lotus-shed command help but probably we want something a little more thorough. Is https://github.com/filecoin-project/lotus/discussions/categories/tutorials enough?

Extension ideas

I am hoping to tweak the python script to take in visualization chart type information so we can visualize same data in a few different ways.

State summary shed command is readily extensible by using a path identifier for protocol areas. We could extend this to breakdown message usage by message type for example.

We could use similar visualization on gas traces. In particular cron gas traces would be useful to keep track of in the same way.

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message. (they will after squash)
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@ZenGround0 ZenGround0 requested a review from a team as a code owner June 28, 2023 15:31
closer func()
}

func loadChainStore(ctx context.Context, repoPath string) (*StoreHandle, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably could have a mode where this loads a snapshot to a memory-map blockstore, would need a decent amount of RAM, but should be much faster

@snissn
Copy link
Contributor

snissn commented Jun 30, 2023

Having this in two branches is causing an issue on the deployment infra. I think this code is good to merge, and all of the comments above are good suggestions that we should open a second issue for.

@ZenGround0
Copy link
Contributor Author

I think this code is good to merge

yup, I just need a green check mark, can you approve @snissn ?

Copy link
Contributor

@snissn snissn left a comment

Choose a reason for hiding this comment

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

looks good to me, has been working and generated expected output for us!

@ZenGround0 ZenGround0 merged commit 1358d70 into master Jul 6, 2023
@ZenGround0 ZenGround0 deleted the feat/stat-snapshot branch July 6, 2023 20:28
Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

Sorry, I never submitted this (partial) review!

type StoreHandle struct {
bs blockstore.Blockstore
cs *store.ChainStore
sm *stmgr.StateManager
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we drop the StateManager here? Conceptually, there isn't any state management you're doing, just a lot of reading of the StateTree. I suspect you'll be able to easily replace calls to sm.StateTree or sm.LoadActor with equivalent operations on the StateTree itslef.

Copy link
Contributor

Choose a reason for hiding this comment

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

Motivation here is that it tends to make things a little more future-proof, and drops a lot of unrelated logic that the StateManager has (migrations, drand, network versions, etc.)

},
&cli.BoolFlag{
Name: "pretty",
Usage: "print formated output instead of ldjson",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Usage: "print formated output instead of ldjson",
Usage: "print formatted output instead of ldjson",

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.

4 participants