Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ template <typename LookupSettings_> class BaseLookupTraceBuilder : public Intera
// find a row dst_row in the target columns {d1, d2, ...} where the values match.
// Then we increment the count in the counts column at dst_row.
// The complexity is O(|src_selector|) * O(find_in_dst).
trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF& src_sel_value) {
assert(src_sel_value == 1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've decided this is kind of testing that visit_column works ok, so it's out of place here

(void)src_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled.

trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF&) {
auto src_values = trace.get_multiple(LookupSettings::SRC_COLUMNS, row);
uint32_t dst_row = find_in_dst(src_values); // Assumes an efficient implementation.
assert(src_values == trace.get_multiple(LookupSettings::DST_COLUMNS, dst_row));

trace.set(LookupSettings::COUNTS, dst_row, trace.get(LookupSettings::COUNTS, dst_row) + 1);
});
}
Expand Down Expand Up @@ -63,10 +62,7 @@ class LookupIntoDynamicTableGeneric : public BaseLookupTraceBuilder<LookupSettin
void init(TraceContainer& trace) override
{
row_idx.reserve(trace.get_column_rows(LookupSettings::DST_SELECTOR));
trace.visit_column(LookupSettings::DST_SELECTOR, [&](uint32_t row, const FF& dst_sel_value) {
assert(dst_sel_value == 1);
(void)dst_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled.

trace.visit_column(LookupSettings::DST_SELECTOR, [&](uint32_t row, const FF&) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is a bit strange to see many occurences of a visitor not using the second argument but I guess that it would be a bit of an "overdesign" to define two different visit_column. I suppose we cannot overload the lambda to call without any second argument but we could overload visit_column with a lambda argument taking only one argument.
Clearly, I can live with the current situation but it is a bit weird seeing a second declared lambda argument without any variable name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I think it's a bit too much to define 2 visitors. It's not so strange not to use one of the params. However we have to keep an eye on this, if most or many uses ignore the value, then we might need to change the visitor to just provide the row number, and you can optionally get the value yourself. The cost might be similar, or even faster for the cases where we would've ignored the value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm providing the value because I get it for free while iterating the map: https://github.com/AztecProtocol/aztec-packages/blob/master/barretenberg/cpp/src/barretenberg/vm2/tracegen/trace_container.cpp#L95

Since it's just a reference, the cost should be negligible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thx for the feedback. I was not really worried about performance even though it is a good consideration as well.

auto dst_values = trace.get_multiple(LookupSettings::DST_COLUMNS, row);
row_idx.insert({ dst_values, row });
});
Expand Down Expand Up @@ -111,11 +107,8 @@ template <typename LookupSettings> class LookupIntoDynamicTableSequential : publ
// Since the trace does not guarantee visiting rows in order, we need to collect the rows.
std::vector<uint32_t> src_rows_in_order;
src_rows_in_order.reserve(trace.get_column_rows(LookupSettings::SRC_SELECTOR));
trace.visit_column(LookupSettings::SRC_SELECTOR, [&](uint32_t row, const FF& src_sel_value) {
assert(src_sel_value == 1);
(void)src_sel_value; // Avoid GCC complaining of unused parameter when asserts are disabled.
src_rows_in_order.push_back(row);
});
trace.visit_column(LookupSettings::SRC_SELECTOR,
[&](uint32_t row, const FF&) { src_rows_in_order.push_back(row); });
std::sort(src_rows_in_order.begin(), src_rows_in_order.end());

for (uint32_t row : src_rows_in_order) {
Expand Down