199 points · by tkfx · 10y ago · 80 comments
Whenever an exception or a logged error / warning happens in production, it shows you the complete source code leading to it, and the full variable state across the entire call stack.
Using Java Bullshifier, we're able to generate random applications with call stacks that can go thousands of frames deep and other quirky behaviors. This helps us make sure the overhead is unnoticed, even in the most extreme cases.
Would be happy to answer any questions.
When I'm waiting several minutes for our app server to startup, I often ponder what life would be like if we had chosen language X or another stack for our application.
I've primarily worked on JRE-based stacks for some time and once a project reaches a certain size developer happiness begins to decline due to large compilation times, app startup times, etc. Even incremental compiling or hot-reloading of classes seems unreliable at a certain app size (either due to memory or some other reason).
It would be neat if there were a tool to generate large and complex apps with various stacks to get a feeling what the developer experience would be like 1-2 years down the road once the app reaches a critical mass.
We adopted https://buckbuild.com/ at work for our android builds, and it has sped it up a lot compared to our previous gradle build process.
There are a bit more details about the design on our blog: http://blog.takipi.com/java-bullshifier-generate-massive-ran...
And the full source code is available on Github: https://github.com/takipi/java-bullshifier
Basically, the tool is built with Groovy (many projects use it as a scripting language for Java), and there are 4 sections to each randomly generated class:
1. Variable definition, with random types, random names, and values.
2. A section that throws exceptions, or prints to the log, according to the config settings for the rate of events. This also includes a “suicide” function that stops the execution of the program.
3. Calls the next method.
4. Random code that never runs.
There are some advanced config settings described in the Github README.md
But this project actually has some serious utility particularly for byte code manipulators are just alternative compilers like AspectJ. Particularly AspectJ as I have seen it fail on things that neither the Eclipse compiler (JDT) or Open JDK fail on.
Of course if someone doesn't care about exceptions, it's just a bad style. Exception in the production log is like red light and alarm sound, BUG-BUG-BUG. I saw projects, which throw stacktrace after stacktrace, gigabytes of stacktraces (and then archived those teralogs and noone ever watched them). But those projects have much more problems, verbose logs is the least of them.
Yes, with heavy framework usage, especially when those frameworks generate proxy classes and wrappers and god knows what, it's often 2-3 lines of useful information between 90 lines of not-so-useful library or even autogenerated code. But only developer can judge it, environment should preserve anything.
I don't like seeing the same 5 stack frames in the same class appear three separate times in a single stack trace. Because what does that stack trace say?
It says it took Foo five function calls -on itself- to figure out it's not responsible for an operation. So Foo asks Bar to do it, and after half a dozen more function calls someone asks Foo all over again. Who takes 5 function calls to figure out it's STILL not responsible for this action. Lather, Rinse, Repeat.
And how do you set a breakpoint in that call tree? Which time do you want to debug it? How many more times was it called before the exception was thrown?
We call the first framework function, which calls the second function with the default values for the arguments that were optional. The second function looks up the application's method using Reflection. Because Reflection code is verbose and has a lot of tricky cases, we want to share code between all places where we call it, so it delegates calling the API in 4 different methods.
Then come up the ServletFilters in an HTTP application, which is an example of pluggable system. If we declare 10 filters, they all do something like check the authentication, gzip the response, check the XSRF token, transform a WebApplicationException into a 404/500 reaponse. Unfortunately they all appear as "ServletFilters" in the stacktrace, until they delegate to the final HTTPServlet itself. Another example of pluggable system is OSGi: Each method call is wrapped in 5 function calls if the method is in another classloader.
There's only one improvement I'm able to imagine: Java could define a pluggable system at the language level, so we don't have to implement them using function calls. This pluggable system stretches for all delegation needs, from OSGi to ServletFilters to apps where the list of delegates were defined by a REST api, etc. Sounds like a big JSR...
I will agree with vbezhenar that Java stack traces are extremely useful. When something has gone wrong with an application in production, it is useful to know the call stack that led to the problem. I know that I didn't just fail in the method `Foo.doFoo()`, I failed in that method which was called by `Baz.doBaz()`. I know these two pieces of code are interacting which is a big clue as to the problem.
vbezhenar also offers good advice that logs of production software should be empty of exceptions and stack traces -- that the presence of anything is the sign of a problem, and thus rare in well-maintained software. Honestly, well-operating production software shouldn't emit any logs at all. Metrics and activity records if you need them, sure, but there's no need for logs. Logs can consequently be used to quickly pinpoint unexpected things happening.
a bit too verbose, but the amount of info I can get from UAT/PROD envs in case of an issue is mostly enough to fix the bug. verbosity can be solved easily by proper rolling & backup of logs, that's not rocket science.
I champion Sentry wherever I go, as it has an outstanding "fold these common explosions into one event" behavior, in addition to managing the _lifecycle_ of an exception/error, from first encounter through resolved in release, to the dreaded reoccurence.
I do keep a terminal open for my curiosity but I'm much happier with computers watching logs than me having to
It gets all the required information (source, stack and variable state), through a native JVM agent that transmits everything directly to the tool.
I remember when developing in VB classic, youd get something lile "error -68377388484". Perhaps you prefer this?
I would love to have that problem. I work with old PHP where frequently it just barfs a fatal error with no stack-trace at all.
With OverOps, you go deep on Java, with every variable value, overlaid on the code across the call stack. Without looking at / relying on logs.
There's a short video here (http://www.overops.com/) and you can see some more samples after you sign up.
How do you debug your non-trivial applications: sprinkling print statements, some real time debugger, channeling your chosen god?
Why do you think that's better?
In C/C++/rust/JavaScript/Python, the last things you see on a failed build/run is usually the detail that will help you fix the problem. The information is organized to be read by someone.
In fact, IMO they aren't verbose enough: they have only the file name of the source file, not the full path.
I will actually try this because as people have mentioned before hiring is broken and this is either a way to exploit and/or bypass some of the inconveniences like coding challenges and the like used to filter non-programmers.
I will see to create a similar rails tool. I intend to test just stress of people who will look at the code and try to understand what it does.
What if I took emacs and cider and helm-cider and fed it 1e6 line long namespace browser?
(edited to note, I'm not sure why I'd want to try that, but I immediately wondered what would happen...)
I think rails does that out of the box.
But...not more than 20k classes? That doesn't really count as "massive Java application" these days, more like an average-sized enterprise app when including all its dependencies. You would at least triple that to reach "massive" scale ;-)
I love it.