Find your most expensive lines of code with Amazon CodeGuru
Amazon CodeGuru is a developer tool powered by machine learning that provides intelligent recommendations for improving code quality and identifying an application’s most expensive lines of code. It performs automated code reviews and provides application performance recommendations.
Amazon CodeGuru Profiler
Amazon CodeGuru Profiler is always searching for application performance optimizations, identifying your most “expensive” lines of code and recommending ways to fix them to reduce CPU utilization, cut compute costs, and improve application performance. For example, CodeGuru Profiler can identify when your application is consuming excessive CPU capacity on a logging routine instead of executing on core business logic.
CodeGuru Profiler continuously analyzes application CPU utilization and latency characteristics to show you where you are spending the most cycles or time in your application. This analysis is presented in an interactive flame graph that helps you visually easily understand which code paths consume the most resources, verify that your application is performing as expected, and uncover areas that can be optimized further.
Flame graphs visualize the performance of your application by aggregating all the stack traces running at a given moment in time. You can use a flame graph to understand which paths consume the most resources, verify that your application is performing as expected, and uncover areas that can be optimized further. For example, method UploadGreyImage is spending $134,868 per year and this is consuming 10.22% wall clock time, so if you didn’t expect it to spend so much time you should investigate.
CodeGuru Profiler automatically identifies performance issues in your application and provides intelligent recommendations on how to remediate them. These recommendations help you identify and optimize the most expensive or resource intensive methods within your code without you needing to be a performance engineering expert. These optimizations help you reduce the cost of your infrastructure, reduce latency, and improve your overall end user experience.
When it sees opportunities to optimize your application performance, Amazon CodeGuru Profiler explains why it is recommending a change, what’s causing the issue, how to resolve it, and where in the code this issue is impacting your application. This recommendation shows you that this expensive line of code costs you $182.16K per year and is spending 2.97 of your active CPU cost. If you follow the suggested resolution steps you will be able to save up to $182.16K.
Amazon CodeGuru Profiler continuously analyzes your application profiles in real-time and detects anomalies in the behavior of your application and its methods. Each anomaly is tracked in the Recommendation report and you can see time series of how the method’s latency behaves over time with anomalies clearly highlighted. If configured, an Amazon SNS notification will also be sent when a new anomaly is detected.
CodeGuru Profiler is designed to continuously run in production with minimal CPU overhead, which means you can leave it on all the time with minimal impact on application performance. This allows you to profile and troubleshoot your application using real customer traffic patterns and easily discover performance issues that might not be detected in your test environment.
Amazon CodeGuru Reviewer
Amazon CodeGuru Reviewer finds issues in your code and recommends how to remediate them. For example, CodeGuru Reviewer detects deviation from best practices for using AWS APIs and SDKs, and also identifies concurrency issues, resource leaks, and incorrect input validation. To begin reviewing code, you can associate existing code repositories on GitHub, GitHub Enterprise, Bitbucket or AWS CodeCommit with CodeGuru.
CodeGuru Reviewer automatically analyzes source code pull requests to find critical issues and provides intelligent recommendations for resolving code defects directly within the pull request. CodeGuru Reviewer identifies code quality issues in nine broad categories:
- AWS best practices: Correct use of AWS APIs (e.g., polling, pagination)
- Java Best Practices: Correct use of popular Java language and library features
- Concurrency: Detects missing synchronization resulting in incorrect functionality or excessive synchronization leading to performance issues.
- Deadlocks: Checks for coordination among concurrent threads
- Resource leaks: Correct handling of resources (e.g., releasing database connections)
- Sensitive information leaks: Leakage of Personally Identifiable Information (e.g., logging credit card details)
- Common code bugs: Hard to find defects such as not creating a client for each lambda invocation
- Code Cloning: Identifies duplicated code that could be consolidated for better code maintainability
- Input Validation: Checks for malformed or malicious data from untrusted sources
In short, Amazon CodeGuru equips your development team with the tools to maintain a high bar of coding standards in the software development process.
Customers can also view all code reviews in the “Code reviews” console page (Reviewer section). The page lists all code review information such as, the status of the code review, the repository, the number of recommendations, and more. Users click on a successfully completed code review to view recommendation details, search for recommendations and see the number of lines analyzed. Users may also give feedback on CodeGuru recommendations by clicking on thumbs up or thumbs down icon below the recommendation.
Customers can get automated code review recommendations for associated repositories for all code (not just incremental changes through pull requests) under a specified code branch. Customer use cases include providing code review recommendations during code migration, code due diligence and periodic code maintainability initiatives. Customers can navigate to the “Repository Analysis” tab in the “Code Reviews” page to trigger a new analysis on a full repository.
With pull request and full repository analysis available, customers onboarding onto Reviewer can 1) associate their repository, 2) initiate a full repository analysis, 3) continuously analyze pull requests with incremental code changes and 4) do a periodic re-scan of the full repository to ensure code quality.