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

using arc'd tmpfile to fix bal(1M) benchmark #637

Merged
merged 2 commits into from
Sep 22, 2022

Conversation

Voxelot
Copy link
Member

@Voxelot Voxelot commented Sep 21, 2022

use Database::default to get a tmpfile rocksdb db instance. This solves problems related to prematurely dropping the tempfile by using an Arc.

@Voxelot Voxelot requested a review from vlopes11 September 21, 2022 23:06
@Voxelot Voxelot changed the title using arc'd tmpfile to fix 1M test case using arc'd tmpfile to fix bal(1M) benchmark Sep 21, 2022
@vlopes11
Copy link
Contributor

If we take that approach, we might create a shared resource that will impact on each iteration of the benchmark.

What if we keep the problem split, first merge #630 and then make another PR to handle this issue? This way, we don't aggregate different responsibilities to the original PR

@Voxelot
Copy link
Member Author

Voxelot commented Sep 22, 2022

If we take that approach, we might create a shared resource that will impact on each iteration of the benchmark.

That is already happening right now in the current implementation of #630, the only difference this PR introduces is making the tempfile safely clonable like everything else in VmBenchPrepared.

Currently, the tempfile lifetime is being managed by the VmBenchPrepared instance, since that is where it's created. Since these VmBenchPrepared instances are cloned and dropped frequently, and they have a shorter lifetime than the shared rocksdb instance being passed around, this is causing the tempfile to drop prematurely.

In order to ensure each test has it's own isolated db, when should be preparing the VM during each setup instead of cloning instances of the prepared state.

fn new_db() -> io::Result<Database> {
TempDir::new().and_then(|t| Database::open(t.as_ref()).map_err(|e| e.into()))
fn new_db() -> Database {
// when rocksdb is enabled, this creates a new db instance with a temporary path
Copy link
Contributor

Choose a reason for hiding this comment

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

Should fuel-core's rocksdb feature be enabled by default on this benchmark then? That way no benchmarks are accidentally done on much more performant RAM databases?

Copy link
Contributor

@vlopes11 vlopes11 left a comment

Choose a reason for hiding this comment

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

lgtm, one optional change

TempDir::new().and_then(|t| Database::open(t.as_ref()).map_err(|e| e.into()))
fn new_db() -> Database {
// when rocksdb is enabled, this creates a new db instance with a temporary path
Database::default()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we just delete this new_db function and instead unwrap_or_default?

@Voxelot Voxelot merged commit 54c7611 into vlopes11/bench Sep 22, 2022
@Voxelot Voxelot deleted the Voxelot/bench-path-drop branch September 22, 2022 18:08
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.

3 participants