mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:44:41 +01:00
Migrate all CARBON_VLOG to the format string variant. (#4284)
This mostly uses a hilarious set of regular expressions to mechanically switch all but two uses, and then manually fixed the last two. There weren't too many. Also simplifies the `vlog` implementation now that it's all going through a format string. This alone has a nice impact on parse and check of about 2% and 1% respectively. The impact on lex in my timings looks like noise (no change in instruction count, unlike the other phases). ``` name old cpu/op new cpu/op delta BM_CompileAPIFileDenseDecls<Phase::Lex>/256 39.1µs ± 3% 38.1µs ± 2% -2.42% (p=0.000 n=20+19) BM_CompileAPIFileDenseDecls<Phase::Lex>/1024 187µs ± 3% 183µs ± 1% -2.30% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Lex>/4096 776µs ± 4% 756µs ± 1% -2.62% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Lex>/16384 3.36ms ± 1% 3.33ms ± 1% -0.90% (p=0.000 n=18+18) BM_CompileAPIFileDenseDecls<Phase::Lex>/65536 14.4ms ± 2% 14.2ms ± 1% -1.41% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Lex>/262144 65.7ms ± 1% 65.2ms ± 2% -0.86% (p=0.002 n=19+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/256 87.5µs ± 1% 86.3µs ± 1% -1.43% (p=0.000 n=19+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/1024 438µs ± 2% 431µs ± 1% -1.54% (p=0.000 n=19+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/4096 1.81ms ± 2% 1.77ms ± 1% -2.12% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/16384 7.54ms ± 1% 7.43ms ± 1% -1.44% (p=0.000 n=19+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/65536 31.2ms ± 1% 30.6ms ± 1% -2.03% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Parse>/262144 133ms ± 1% 130ms ± 1% -1.85% (p=0.000 n=20+20) BM_CompileAPIFileDenseDecls<Phase::Check>/256 882µs ± 1% 878µs ± 1% -0.52% (p=0.001 n=17+19) BM_CompileAPIFileDenseDecls<Phase::Check>/1024 1.90ms ± 2% 1.88ms ± 1% -1.17% (p=0.000 n=19+19) BM_CompileAPIFileDenseDecls<Phase::Check>/4096 5.85ms ± 2% 5.76ms ± 1% -1.43% (p=0.000 n=20+19) BM_CompileAPIFileDenseDecls<Phase::Check>/16384 22.2ms ± 2% 21.9ms ± 2% -1.20% (p=0.000 n=20+19) BM_CompileAPIFileDenseDecls<Phase::Check>/65536 91.2ms ± 2% 90.3ms ± 1% -1.00% (p=0.000 n=20+19) BM_CompileAPIFileDenseDecls<Phase::Check>/262144 382ms ± 1% 380ms ± 1% -0.51% (p=0.003 n=18+19) ```
This commit is contained in:
+16
-18
@@ -503,8 +503,8 @@ class DeferredDefinitionWorklist {
|
||||
-> void {
|
||||
worklist_.push_back(CheckSkippedDefinition{
|
||||
index, HandleFunctionDefinitionSuspend(context, node_id)});
|
||||
CARBON_VLOG() << VlogPrefix << "Push CheckSkippedDefinition " << index.index
|
||||
<< "\n";
|
||||
CARBON_VLOG("{0}Push CheckSkippedDefinition {1}\n", VlogPrefix,
|
||||
index.index);
|
||||
}
|
||||
|
||||
// Push a task to re-enter a function scope, so that functions defined within
|
||||
@@ -519,8 +519,8 @@ class DeferredDefinitionWorklist {
|
||||
worklist_.push_back(
|
||||
EnterDeferredDefinitionScope{.suspended_name = std::nullopt,
|
||||
.in_deferred_definition_scope = nested});
|
||||
CARBON_VLOG() << VlogPrefix << "Push EnterDeferredDefinitionScope "
|
||||
<< (nested ? "(nested)" : "(non-nested)") << "\n";
|
||||
CARBON_VLOG("{0}Push EnterDeferredDefinitionScope {1}\n", VlogPrefix,
|
||||
nested ? "(nested)" : "(non-nested)");
|
||||
}
|
||||
|
||||
// Suspend the current deferred definition scope, which is finished but still
|
||||
@@ -535,19 +535,18 @@ class DeferredDefinitionWorklist {
|
||||
VariantMatch(
|
||||
worklist_.back(),
|
||||
[&](CheckSkippedDefinition& definition) {
|
||||
CARBON_VLOG() << VlogPrefix << "Handle CheckSkippedDefinition "
|
||||
<< definition.definition_index.index << "\n";
|
||||
CARBON_VLOG("{0}Handle CheckSkippedDefinition {1}\n", VlogPrefix,
|
||||
definition.definition_index.index);
|
||||
},
|
||||
[&](EnterDeferredDefinitionScope& enter) {
|
||||
CARBON_CHECK(enter.in_deferred_definition_scope);
|
||||
CARBON_VLOG() << VlogPrefix
|
||||
<< "Handle EnterDeferredDefinitionScope (nested)\n";
|
||||
CARBON_VLOG("{0}Handle EnterDeferredDefinitionScope (nested)\n",
|
||||
VlogPrefix);
|
||||
},
|
||||
[&](LeaveDeferredDefinitionScope& leave) {
|
||||
bool nested = leave.in_deferred_definition_scope;
|
||||
CARBON_VLOG() << VlogPrefix
|
||||
<< "Handle LeaveDeferredDefinitionScope "
|
||||
<< (nested ? "(nested)" : "(non-nested)") << "\n";
|
||||
CARBON_VLOG("{0}Handle LeaveDeferredDefinitionScope {1}\n",
|
||||
VlogPrefix, nested ? "(nested)" : "(non-nested)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -592,7 +591,7 @@ auto DeferredDefinitionWorklist::SuspendFinishedScopeAndPush(Context& context)
|
||||
if (start_index == worklist_.size() - 1) {
|
||||
context.decl_name_stack().PopScope();
|
||||
worklist_.pop_back();
|
||||
CARBON_VLOG() << VlogPrefix << "Pop EnterDeferredDefinitionScope (empty)\n";
|
||||
CARBON_VLOG("{0}Pop EnterDeferredDefinitionScope (empty)\n", VlogPrefix);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -607,8 +606,7 @@ auto DeferredDefinitionWorklist::SuspendFinishedScopeAndPush(Context& context)
|
||||
// Enqueue a task to leave the nested scope.
|
||||
worklist_.push_back(
|
||||
LeaveDeferredDefinitionScope{.in_deferred_definition_scope = true});
|
||||
CARBON_VLOG() << VlogPrefix
|
||||
<< "Push LeaveDeferredDefinitionScope (nested)\n";
|
||||
CARBON_VLOG("{0}Push LeaveDeferredDefinitionScope (nested)\n", VlogPrefix);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -617,8 +615,8 @@ auto DeferredDefinitionWorklist::SuspendFinishedScopeAndPush(Context& context)
|
||||
// scope and end checking deferred definitions.
|
||||
worklist_.push_back(
|
||||
LeaveDeferredDefinitionScope{.in_deferred_definition_scope = false});
|
||||
CARBON_VLOG() << VlogPrefix
|
||||
<< "Push LeaveDeferredDefinitionScope (non-nested)\n";
|
||||
CARBON_VLOG("{0}Push LeaveDeferredDefinitionScope (non-nested)\n",
|
||||
VlogPrefix);
|
||||
|
||||
// We'll process the worklist in reverse index order, so reverse the part of
|
||||
// it we're about to execute so we run our tasks in the order in which they
|
||||
@@ -632,8 +630,8 @@ auto DeferredDefinitionWorklist::SuspendFinishedScopeAndPush(Context& context)
|
||||
holds_alternative<EnterDeferredDefinitionScope>(worklist_.back()))
|
||||
<< "Unexpected task in worklist.";
|
||||
worklist_.pop_back();
|
||||
CARBON_VLOG() << VlogPrefix
|
||||
<< "Handle EnterDeferredDefinitionScope (non-nested)\n";
|
||||
CARBON_VLOG("{0}Handle EnterDeferredDefinitionScope (non-nested)\n",
|
||||
VlogPrefix);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user