5 ms·
Isn't the point that you don't generally stuff your log of things that are only strings but of things that can become strings? (Asking since I know of your work
by alserio 5y ago
Isn't the point that you don't generally stuff your log of things that are only strings but of things that can become strings?
(Asking since I know of your work with truffle)
- chrisseaton 5y agoI assumed things like the names of resources that are already strings because you’re using them in the actual program?
- alserio 5y agoA typical logger.info("user {} did the thing", user) can skip the actual string interpolation and user value stringification, if the log level is not > info. However, logger.info("user " + user + " did the thing") cannot avoid at least the execution of user.toString(), even after jit optimizations, unless the jit could prove that toString does not have side effects. But I don't believe the jvm jit tries to do that. Am I wrong?
- chrisseaton 5y agoIf user is a string, then #toString() is a trivial method, will inline, and become a no-op.
- alserio 5y agoHowever, if user happened be an user-defined User object it would be hard to guarantee that it could be inlined
- chrisseaton 5y agoYes