Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Optimize contract engine for concurrency #950

Closed
aeyakovenko opened this issue Aug 11, 2018 · 6 comments
Closed

Optimize contract engine for concurrency #950

aeyakovenko opened this issue Aug 11, 2018 · 6 comments
Assignees
Milestone

Comments

@aeyakovenko
Copy link
Member

aeyakovenko commented Aug 11, 2018

Multi threaded banks need to atomically unlock accounts and linearize the blobs they produce. Otherwise there may be an error replaying the ledger as the blobs get out of order. Some of this work is addressed in #1368

This is what is implemented in #1368

  1. PoHRecorder breaks up transactions into chunks that could fit into a blob
  2. banking stage for mt banks call poh_recoder.record(txs: Vec)
  3. Blob gets full, PoHRecorder atomically calls
  • call bank.unlock_accounts(txs: Vec)
  • poh.record(Blob's hash)
  • sender.send(Entry for Blob)
  • call bank.register_entry_id for the Entry only
  1. concurrently banking stage calls poh_recorder.tick(), which atomically does the following:
  • also emit the poh Tick
  • call bank.register_entry_id for the Tick entry
  • sender.send(Tick)
  1. bank.process_entry only calls bank.register_entry_id for every entry

This is the proposed solution

  1. PoHRecorder holds a pending blob.
  2. banking stage for mt banks call poh_recoder.record(txs: Vec)
  3. Blob gets full, PoHRecorder atomically calls
  • call bank.unlock_accounts(txs: Vec)
  • poh.record(Blob's hash)
  • sender.send(Entry for Blob)
  1. concurrently banking stage calls poh_recorder.tick(), which atomically does the following:
  • if sender.send has not been called in more then 1 tick (100ms), do the same work as in poh.record with the current partial blob blob
  • also emit the Tick
  • call bank.register_entry_id for the Tick entry only
  • sender.send(Tick)
  1. bank.process_entry only calls bank.register_entry_id for the Tick

@garious @rob-solana (captured the todo's left from #1368)

@rob-solana rob-solana changed the title effecient bob emitter effecient blob emitter Aug 11, 2018
@rob-solana
Copy link
Contributor

how does this batching proposal differ from what's done today? do multiple batches in the blob have to be identified as blocks that can be handled in parallel?

@aeyakovenko
Copy link
Member Author

@rob-solana what the code does right now is construct entries (allocation + copy), then stick them into blobs (a copy). instead of writing into blobs then sending them out to IO. since you are not binning at the IO boundary, you have no idea how to construct the entry in such a way that it fits in whatever space is left in the blob.

This was referenced Aug 11, 2018
@mvines mvines added this to the v0.9.0 milestone Aug 13, 2018
@mvines mvines modified the milestones: v0.9 Swamis, The Future! Sep 11, 2018
@aeyakovenko aeyakovenko changed the title effecient blob emitter Optimize contract engine for concurrency Oct 1, 2018
@aeyakovenko aeyakovenko modified the milestones: The Future!, v0.10 Pillbox Oct 1, 2018
@rob-solana
Copy link
Contributor

this issue and the mt-bank PR don't look in sync anymore. are they?

@garious
Copy link
Contributor

garious commented Oct 2, 2018

No, one of @aeyakovenko's comments on that PR said that he considered it out of scope.

@mvines
Copy link
Contributor

mvines commented Oct 23, 2018

@aeyakovenko, are we optimized? Anything more that needs to be done here?

@aeyakovenko
Copy link
Member Author

woot! optimized!

vkomenda pushed a commit to vkomenda/solana that referenced this issue Aug 29, 2021
* Add proptests for single token conversion

* Update token-swap/program/src/curve/calculator.rs

Co-authored-by: Tyera Eulberg <[email protected]>

* Update token-swap/program/src/curve/calculator.rs

Co-authored-by: Tyera Eulberg <[email protected]>

* Revert change from fuzzing

* Reduce the constant price b->a test range

* Use constant for basis points guarantee

* Address review feedback

Co-authored-by: Tyera Eulberg <[email protected]>
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

4 participants