-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 maximum table columns from 64 to 320 #6094
Conversation
Hello and thanks for the PR. This seems indeed like a tweaking of #3572. As mentioned in that issue, I'm not sure about the added cost of this, increasing mask size from 32 to 160 bytes spreading those fields over more cache-lines to handle a rare scenario, while keeping an arbitrary compile-time limit. Going to add try adding more formal perf tests in the Test Suite, namely I think we should go for all 4 combinations of table with few/many columns/rows and compare perfs of all fours with/without the change. I want to see if I can achieve the best of both worlds and fully lift lifting by allocating those via the I think I've got a base good enough with all our PR to attempt a rework. I'm also going to probably remove |
For references, I applied this PR (over db55422 which should have benefited it slightly) With this code: // Shared function to test basic table performances.
struct TablePerfFuncVars { int TablesCount = 1; int RowsCount = 50; int ColumnsCount = 3; };
auto TablePerfFunc = [](ImGuiTestContext* ctx)
{
auto& vars = ctx->GetVars<TablePerfFuncVars>();
ImGui::SetNextWindowSize(ImVec2(800, 800));
ImGui::Begin("Test Func", NULL, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize);
const int tables_count = vars.TablesCount;
const int columns_count = vars.ColumnsCount;
const int rows_count = vars.RowsCount;
if (ctx->IsFirstGuiFrame())
ctx->LogDebug("%d tables x %d columns x %d rows", tables_count, columns_count, rows_count);
for (int n = 0; n < tables_count; n++)
{
ImGui::PushID(n);
if (ImGui::BeginTable("table1", columns_count, ImGuiTableFlags_BordersV))
{
for (int row = 0; row < rows_count; row++)
{
for (int col = 0; col < columns_count; col++)
{
ImGui::TableNextColumn();
if (col == 0)
ImGui::Text("Cell 0,%d", n);
else if (col == 1)
ImGui::TextUnformatted("Cell 1");
else if (col == 2)
ImGui::TextUnformatted("Cell 2");
// No output on further columns to not interfere with performances more than necessary
}
}
ImGui::EndTable();
}
ImGui::Separator();
ImGui::PopID();
}
ImGui::End();
};
// ## Measure the cost of TableNextCell(), TableNextRow(): one table, few columns, many rows
t = IM_REGISTER_TEST(e, "perf", "perf_tables_basic_tables_lo_cols_lo_rows_hi");
t->SetVarsDataType<TablePerfFuncVars>([](ImGuiTestContext* ctx, auto& vars)
{
vars.TablesCount = 1;
vars.ColumnsCount = 3;
vars.RowsCount = 100 * ctx->PerfStressAmount;
});
t->GuiFunc = TablePerfFunc;
t->TestFunc = PerfCaptureFunc;
// ## Measure the cost of BeginTable(): many tables, few columns, few rows
t = IM_REGISTER_TEST(e, "perf", "perf_tables_basic_tables_hi_cols_lo_rows_lo");
t->SetVarsDataType<TablePerfFuncVars>([](ImGuiTestContext* ctx, auto& vars)
{
vars.TablesCount = 30 * ctx->PerfStressAmount;
vars.ColumnsCount = 3;
vars.RowsCount = 3;
});
t->GuiFunc = TablePerfFunc;
t->TestFunc = PerfCaptureFunc;
// ## Measure the cost of BeginTable(): many tables, many columns, few rows
t = IM_REGISTER_TEST(e, "perf", "perf_tables_basic_tables_hi_cols_hi_rows_lo");
t->SetVarsDataType<TablePerfFuncVars>([](ImGuiTestContext* ctx, auto& vars)
{
vars.TablesCount = 30 * ctx->PerfStressAmount;
vars.ColumnsCount = 32;
vars.RowsCount = 3;
});
t->GuiFunc = TablePerfFunc;
t->TestFunc = PerfCaptureFunc;
// ## Measure the cost of BeginTable(): one table, many columns, many rows
t = IM_REGISTER_TEST(e, "perf", "perf_tables_basic_tables_lo_cols_hi_rows_hi");
t->SetVarsDataType<TablePerfFuncVars>([](ImGuiTestContext* ctx, auto& vars)
{
vars.TablesCount = 1;
vars.ColumnsCount = 32;
vars.RowsCount = 30 * ctx->PerfStressAmount;
});
t->GuiFunc = TablePerfFunc;
t->TestFunc = PerfCaptureFunc; |
Pushed my version of this as db55422 + 14908cb + 9166743, closing #6094, #5305, #4876, #3572. TL;DR;
The four tests are now as fast as with previous code: Original PR (Debug) vs final solution (Debug) Thanks everyone for your input on that! |
Fantastic - thank you! I'll try it out today. Roland |
Increase the maximum number of columns in tables from 64 to 320.
This PR is developed from a patch file originally contributed by @Necrolis in issue #3572.
I've been applying these changes to various versions of ImGui on Kubuntu for approximately 2 years and have had no issues with tables larger than 64 columns. It works well combined with the clipper.