Skip to content

feat(accounts-db): support fast loading #324

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

Closed
wants to merge 12 commits into from
12 changes: 6 additions & 6 deletions scripts/view_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import random

def random_color_generator():
# take [r, g, b] from colormap
# Dark2 chosen for visibility from
# https://matplotlib.org/stable/users/explain/colors/colormaps.html#qualitative
return plt.colormaps["Dark2"](random.random())[:3]
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
return (r / 255, g / 255, b / 255)

def view_results(paths):
path = paths[0]
Expand Down Expand Up @@ -40,8 +40,8 @@ def view_results(paths):
for i in range(len(benchmark_names)):
plt.clf()
plt.title(benchmark_names[i], wrap=True)

for df_i, df in enumerate(dfs):
label = paths[df_i]
# remove the header and the benchmark name
benchmark_runtimes = df.T[2:][i]
benchmark_runtimes.replace('', np.nan, inplace=True)
Expand All @@ -51,7 +51,7 @@ def view_results(paths):

color = colors[df_i]
mean = np.mean(benchmark_runtimes)
plt.scatter(benchmark_runtimes, np.zeros_like(benchmark_runtimes), color=color, label=paths[df_i])
plt.scatter(benchmark_runtimes, np.zeros_like(benchmark_runtimes), color=color, label=label)

var = np.var(benchmark_runtimes)
plt.errorbar(mean, 1, xerr=np.sqrt(var), fmt='o', color=color) # mean
Expand Down
617 changes: 345 additions & 272 deletions src/accountsdb/db.zig

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/accountsdb/fuzz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub fn run(seed: u64, args: *std.process.ArgIterator) !void {
.number_of_index_shards = sig.accounts_db.db.ACCOUNT_INDEX_SHARDS,
.use_disk_index = use_disk,
.lru_size = 10_000,
.prealloc_number_of_accounts = 1_000_000,
// TODO: other things we can fuzz (number of shards, ...)
},
null,
Expand Down Expand Up @@ -334,7 +335,7 @@ pub fn run(seed: u64, args: *std.process.ArgIterator) !void {
var alt_accounts_db = try AccountsDB.init(allocator, .noop, alternative_snapshot_dir, accounts_db.config, null);
defer alt_accounts_db.deinit();

_ = try alt_accounts_db.loadWithDefaults(allocator, &snapshot_fields, 1, true, 1_500);
_ = try alt_accounts_db.loadWithDefaults(allocator, &snapshot_fields, 1, true, 500, false, false);
const maybe_inc_slot = if (snapshot_files.incremental_snapshot) |inc| inc.slot else null;
logger.info().logf("loaded and validated snapshot at slot: {} (and inc snapshot @ slot {any})", .{ snapshot_info.slot, maybe_inc_slot });
}
Expand Down
Loading