Skip to content
Snippets Groups Projects
Unverified Commit 23a94596 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Log some info about pass calculation for mutable shares

parent ee6b7bc3
No related branches found
No related tags found
1 merge request!166More spending logging
......@@ -80,3 +80,33 @@ CALL_WITH_PASSES = ActionType(
[],
u"A storage operation is being started which may spend some passes.",
)
CURRENT_SIZES = Field(
u"current_sizes",
dict,
u"A dictionary mapping the numbers of existing shares to their existing sizes.",
)
TW_VECTORS_SUMMARY = Field(
u"tw_vectors_summary",
dict,
u"A dictionary mapping share numbers from tw_vectors to test and write vector summaries.",
)
NEW_SIZES = Field(
u"new_sizes",
dict,
u"A dictionary like that of CURRENT_SIZES but for the sizes computed for the shares after applying tw_vectors.",
)
NEW_PASSES = Field(
u"new_passes",
int,
u"The number of passes computed as being required for the change in size.",
)
MUTABLE_PASSES_REQUIRED = MessageType(
u"zkapauthorizer:storage:mutable-passes-required",
[CURRENT_SIZES, TW_VECTORS_SUMMARY, NEW_SIZES, NEW_PASSES],
u"Some number of passes has been computed as the cost of updating a mutable.",
)
......@@ -30,6 +30,10 @@ from .validators import (
greater_than,
)
from .eliot import (
MUTABLE_PASSES_REQUIRED,
)
@attr.s(frozen=True)
class MorePassesRequired(Exception):
"""
......@@ -180,8 +184,9 @@ def get_implied_data_length(data_vector, new_length):
def get_required_new_passes_for_mutable_write(pass_value, current_sizes, tw_vectors):
"""
:param int pass_value: The value of a single pass in byte-months.
:param current_sizes:
"""
# print("get_required_new_passes_for_mutable_write({}, {})".format(current_sizes, summarize(tw_vectors)))
current_passes = required_passes(
pass_value,
current_sizes.values(),
......@@ -204,16 +209,23 @@ def get_required_new_passes_for_mutable_write(pass_value, current_sizes, tw_vect
)
required_new_passes = new_passes - current_passes
# print("Current sizes: {}".format(current_sizes))
# print("Current passes: {}".format(current_passes))
# print("New sizes: {}".format(new_sizes))
# print("New passes: {}".format(new_passes))
MUTABLE_PASSES_REQUIRED.log(
current_sizes=current_sizes,
tw_vectors_summary=summarize(tw_vectors),
current_passes=current_passes,
new_sizes=new_sizes,
new_passes=new_passes,
)
return required_new_passes
def summarize(tw_vectors):
return {
sharenum: (
test_vector,
list(
(offset, length, operator, len(specimen))
for (offset, length, operator, specimen)
in test_vector
),
list(
(offset, len(data))
for (offset, data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment