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

Increase cache for RockDB by column #5212

Merged
merged 7 commits into from
Nov 13, 2021
Merged

Increase cache for RockDB by column #5212

merged 7 commits into from
Nov 13, 2021

Conversation

pmnoxx
Copy link
Contributor

@pmnoxx pmnoxx commented Nov 12, 2021

We recently found out that our rockdb is not efficient enough.
Therefore we would like to increase cache size of specific columns.
In this PR we will increase cache size for DBCol::ColState to 128mb.

We can adjust that cache size later, but we try to be conservative in memory usage.
Some testing should be done to determine optimize cache sizes.

Closes #5203

@pmnoxx pmnoxx self-assigned this Nov 12, 2021
Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

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

Thanks!

core/store/src/db.rs Outdated Show resolved Hide resolved
@pmnoxx pmnoxx marked this pull request as ready for review November 12, 2021 06:31
@pmnoxx
Copy link
Contributor Author

pmnoxx commented Nov 12, 2021

@bowenwang1996 Ok, I updated the cache size.

@near-bulldozer near-bulldozer bot merged commit c1029a9 into near:master Nov 13, 2021
@pmnoxx pmnoxx deleted the piotr-increase-cache-for-colstate branch November 13, 2021 06:25
pmnoxx added a commit that referenced this pull request Nov 20, 2021
We recently found out that our rockdb is not efficient enough.
Therefore we would like to increase cache size of specific columns.
In this PR we will increase cache size for `DBCol::ColState` to 128mb.

We can adjust that cache size later, but we try to be conservative in memory usage. 
Some testing should be done to determine optimize cache sizes. 


Closes #5203
@pmnoxx pmnoxx added A-store C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Priority: low labels Dec 5, 2021
near-bulldozer bot pushed a commit that referenced this pull request Dec 8, 2021
Increase trie cache size to mitigate receipts undercharging issue.

## Validity

We can increase cache size to 50_000, so the theoretical occupied size is 50_000 * 4 (num_shards) * 4_000 = 800 MB.

In reality, `/usr/bin/time -v ` shows **520 -> 1070 MB** RAM growth which seem to be caused by #5212. This change have an impact like 30 MB.
I've additionally checked that cache is full on my runs.

## Speedup

On the sample of 30 receipts we considered, we have the following characteristics:

```
default settings: summary time = 3.3s, avg undercharging = 101
increase state cache size: summary time = 0.67s, avg undercharging = 21
increase state cache size + trie cache size = 50k: summary time = 0.5s, avg undercharging = 11.5
increase state cache size + trie cache size = 100k + reduce max value size to 1k: summary time = 0.3s, avg undercharging = 6.9
```

For now, let's just increase cache size. On this sample we reduce undercharging 2x and summary execution time 1.3x.

## Testing

* checking that cache is full;
* existing tests,
* estimating `/usr/bin/time -v ./state-viewer apply_range --start_index 54051433 --end_index 54053438 --shard_id 3`
bowenwang1996 pushed a commit that referenced this pull request Dec 20, 2021
Increase trie cache size to mitigate receipts undercharging issue.

## Validity

We can increase cache size to 50_000, so the theoretical occupied size is 50_000 * 4 (num_shards) * 4_000 = 800 MB.

In reality, `/usr/bin/time -v ` shows **520 -> 1070 MB** RAM growth which seem to be caused by #5212. This change have an impact like 30 MB.
I've additionally checked that cache is full on my runs.

## Speedup

On the sample of 30 receipts we considered, we have the following characteristics:

```
default settings: summary time = 3.3s, avg undercharging = 101
increase state cache size: summary time = 0.67s, avg undercharging = 21
increase state cache size + trie cache size = 50k: summary time = 0.5s, avg undercharging = 11.5
increase state cache size + trie cache size = 100k + reduce max value size to 1k: summary time = 0.3s, avg undercharging = 6.9
```

For now, let's just increase cache size. On this sample we reduce undercharging 2x and summary execution time 1.3x.

## Testing

* checking that cache is full;
* existing tests,
* estimating `/usr/bin/time -v ./state-viewer apply_range --start_index 54051433 --end_index 54053438 --shard_id 3`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Priority: low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding LRU cache to RocksDB impl of Database
2 participants