Closed codefromthecrypt closed 9 months ago
going to try to add InfoS/ErrorS now. mostly an exercise in copying logic and backfilling tests
polished and stubbed structured logging.
next step: implement it
I like this approach. Please go ahead 👍
OK I will finish this up, but I won't have time to implement the structured log in the same PR (will leave the signatures for a later change). Will mark ready for review when ready.
Added the commit from #69 to proceed further. Will try to finish structured logging in the same PR
Ok I've gotten this far, but something's wrong with k/v on the host side. Will look into it later
I0802 15:18:53.788082 34631 host.go:219] NodeNumberArgs is successfully applied
I0802 15:18:53.788393 34631 host.go:264] "execute PreScore on NodeNumber plugin" pod="(MISSING)"
I0802 15:18:53.788411 34631 host.go:264] "execute Score on NodeNumber plugin" pod="(MISSING)"
So, what's left here is..
newNodeNumberPlugin
revert to LogSeverity: 3, // FatalLog
ExampleInfoS
like we have ExampleInfo
with use like in NodeNumberPluginExampleError
and ExampleErrorS
like we have ExampleInfo
from some existing code in a real pluginI pushed 4 distinct commits so that you can pick any of these changes if you think they help:
all.go
for tinygo logPlugin
which is just the same as params
except it should also log them, but I did not figure out where to put the actual test cases; also it felt a bit redundant because of (2); but maybe you had something different in mindfeel free to drop all of them if they are not useful!
Thanks for all the help @evacchi I will go through and do any buttoning up once #69 merges, which might be monday due to some of us having typhoon displacement ;)
squashed work so far and will move this to the finish line soon. Thanks a lot @evacchi!
@sanposhiho I'm marking ready for review even if I have some test cases to backfill. You can see in the PR desc that logging enabled vs disabled makes a difference in performance, which means our ABI is working! Thanks to @evacchi for the collaboration on this.
ok ready. only other refactoring will be separate PR as I want to see if we can avoid using "wat" format too much.
The main thing here is we can see that the advanced plugin perf is within the margin of error (comparable to before), and when logging is switched on, it drops 13% (7us) per run, which makes sense as logging is expensive.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: codefromthecrypt, sanposhiho
The full list of commands accepted by this bot can be found here.
The pull request process is described here
What type of PR is this?
/kind feature
What this PR does / why we need it:
This begins klog support with the simplest api used in plugins:
klog.Info
,klog.InfoS
,klog.Error
andklog.ErrorS
Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
klog.InfoS
, where the KVs are encoded NUL-terminated to the host.klog.KObj
used reflection too much which caused things like crashing the compiler or poor performance. This ports the intent more simply.Does this PR introduce a user-facing change?
NONE
What are the benchmark results of this change?
Performance of Simple is wild because it uses the default GC and the plugin is heavy due to protos. Advanced uses nottinygc and also separates out code that uses imports so that they can be more easily tested. These notes are in the READMEs.
The main thing here is that performance of Advanced/Run is the same when logging is disabled, and it drops 13% (7us) per Run when enabled. This shows the deferred stringification works, but also shows logging has a measurable cost even when only a couple times.