Skip to content

Conversation

@ggawryal
Copy link

Description

PR removing the limit of 32 blocks on the same level (having the same number) in substrate. This limit is enforced only by one some component of state-db that keeps imported, noncanonicalized blocks and it seems it is only enforced for the sake of simpler implementation in paritytech/substrate#8494.

This PR removes that limit by applying the suggestion in the introducing PR, by keeping the span (length) of the overlay level in noncanonicalized blocks. To avoid making extra db queries, the span is kept only if we have more than 32 blocks on the same level (should be an extremely rare case, as these blocks are validated). Moreover, blocks on one were previously indexed on overlay level using a bitmask of length 64. This is changed now to keeping an ordered set of unused indices, adding an O(log b) overhead, where |b| is the number of blocks on the same level.

Tested in aleph-node on test client (using db backend) - successfully imported 10k blocks on the same level, and then finalized the last one. It took 8.01s on my laptop, while, for comparison, importing a branch of 10k blocks took 6.39s.

@ggawryal ggawryal changed the title A0-3582: Deal with block limit [DON'T MERGE] A0-3582: Deal with block limit Jan 11, 2024
lesniak43 pushed a commit that referenced this pull request Mar 19, 2024
1. Benchmark results are collected in a single struct.
2. The output of the results is prettified.
3. The result struct used to save the output as a yaml and store it in
artifacts in a CI job.

```
$ cargo run -p polkadot-subsystem-bench --release -- test-sequence --path polkadot/node/subsystem-bench/examples/availability_read.yaml | tee output.txt
$ cat output.txt

polkadot/node/subsystem-bench/examples/availability_read.yaml #1

Network usage, KiB                     total   per block
Received from peers               510796.000  170265.333
Sent to peers                        221.000      73.667

CPU usage, s                           total   per block
availability-recovery                 38.671      12.890
Test environment                       0.255       0.085


polkadot/node/subsystem-bench/examples/availability_read.yaml #2

Network usage, KiB                     total   per block
Received from peers               413633.000  137877.667
Sent to peers                        353.000     117.667

CPU usage, s                           total   per block
availability-recovery                 52.630      17.543
Test environment                       0.271       0.090


polkadot/node/subsystem-bench/examples/availability_read.yaml #3

Network usage, KiB                     total   per block
Received from peers               424379.000  141459.667
Sent to peers                        703.000     234.333

CPU usage, s                           total   per block
availability-recovery                 51.128      17.043
Test environment                       0.502       0.167

```

```
$ cargo run -p polkadot-subsystem-bench --release -- --ci test-sequence --path polkadot/node/subsystem-bench/examples/availability_read.yaml | tee output.txt
$ cat output.txt
- benchmark_name: 'polkadot/node/subsystem-bench/examples/availability_read.yaml #1'
  network:
  - resource: Received from peers
    total: 509011.0
    per_block: 169670.33333333334
  - resource: Sent to peers
    total: 220.0
    per_block: 73.33333333333333
  cpu:
  - resource: availability-recovery
    total: 31.845848445
    per_block: 10.615282815
  - resource: Test environment
    total: 0.23582828799999941
    per_block: 0.07860942933333313

- benchmark_name: 'polkadot/node/subsystem-bench/examples/availability_read.yaml #2'
  network:
  - resource: Received from peers
    total: 411738.0
    per_block: 137246.0
  - resource: Sent to peers
    total: 351.0
    per_block: 117.0
  cpu:
  - resource: availability-recovery
    total: 18.93596025099999
    per_block: 6.31198675033333
  - resource: Test environment
    total: 0.2541994199999979
    per_block: 0.0847331399999993

- benchmark_name: 'polkadot/node/subsystem-bench/examples/availability_read.yaml #3'
  network:
  - resource: Received from peers
    total: 424548.0
    per_block: 141516.0
  - resource: Sent to peers
    total: 703.0
    per_block: 234.33333333333334
  cpu:
  - resource: availability-recovery
    total: 16.54178526900001
    per_block: 5.513928423000003
  - resource: Test environment
    total: 0.43960946299999537
    per_block: 0.14653648766666513
```

---------

Co-authored-by: Andrei Sandu <[email protected]>
@ggawryal
Copy link
Author

Closing, as this should be rather merged in the upstream: paritytech#2933

@ggawryal ggawryal closed this May 21, 2024
@ggawryal ggawryal changed the title [DON'T MERGE] A0-3582: Deal with block limit A0-3582: Deal with block limit Jun 24, 2024
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.

2 participants