Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for frequency logging #21

Merged
merged 81 commits into from
Jun 4, 2024
Merged

Adding support for frequency logging #21

merged 81 commits into from
Jun 4, 2024

Conversation

kartikeytewari-ul
Copy link
Contributor

@kartikeytewari-ul kartikeytewari-ul commented Dec 19, 2023

Frequency Logging Enhancement

Overview

Introducing the Frequency Logging feature, which enables frequency based stack call logging in Java programs at pre-defined intervals. This flexibility is achieved by setting the logging frequency at compile time, with options available at the program, class, and method level.

Annotation Options

The logging frequency can be easily specified using annotations. The new annotation options are:

  • @Unlogged(loggingFrequency = some_string): Sets the logging frequency for the entire programme.
  • @UnloggedClass(loggingFrequency = some_string): Defines the logging frequency at the class level.
  • @UnloggedMethod(loggingFrequency = some_string): Specifies the logging frequency at the method level.

Method Compilation States:

A compiled method falls into one of three states:

  1. Always probed: only methodVisitorProbed is called
  2. Never probed: no method visitor is invoked
  3. Conditionally probed: both methodVisitorProbed and methodVisitorWithoutProbe are called

Implementation Details

The feature is implemented as follows:

  • Annotation Processing: Two annotation visitor traverses each annotated class and method. They store values in classCounterMap and methodCounterMap respectively.
  • Probe Counter and Frequency Logging: Adds probeCounter and the frequencyLogging method at runtime to determine whether a method should be logged.
  • Static Field Initialisation: A static field () is required for initialising the mapStore. For class with starting method, a initialising method is already made. So, initialisation occurs within the same method. For other classes, a new static method is created.
  • DualMethodVisitor: It is a POJO that encapsulates both methodVisitorProbed and methodVisitorWithoutProbe.

By following these implementation details, the Frequency Logging enhancement ensures precise control over stack call logging in Java programs.

Sanity Testing

  • The PR was tested using three tests. The github workflow for compile and replay target of SDK was run. They are passing correctly. Also, this was tested using auto executor. The configuration for the same is:
  1. version 0.2.0
  • Project: branch main of unlogged-spring-maven-demo
  • Total number of cases run : 368
  • Number of Passing cases : 112
  • Number of Failing cases : 256
  1. version freq_logging
  • Project: branch test_freq_logging of unlogged-spring-maven-demo
  • Total number of cases run : 368
  • Number of Passing cases : 112
  • Number of Failing cases : 256
  • The tests that were failing/passing were identical for both the sdks.

- add annotation for class
- add annotation for method
- add asm logic for class annotation
- move CustomMethodVisitor to a seperate file
- rename internal parameters of CustomMethodVisitor to be more readable
- remove some logs from class transformer
- modified get_counter to static method
- refactor variable names
- refactor divisor setting logic
- refactor pushArgument to handlen all pushing of variables to stack
- pass all invoke arguments to probeCounter
@kartikeytewari-ul kartikeytewari-ul marked this pull request as ready for review January 1, 2024 09:39
@kartikeytewari-ul kartikeytewari-ul changed the title [Draft] Adding support for frequency logging Adding support for frequency logging Jan 1, 2024
@kartikeytewari-ul
Copy link
Contributor Author

The replay_target pipeline is failing because the tests defined in the python file are not present in the project test resources. Once, updated this test needs to run again.

@artpar artpar merged commit 8c843be into main Jun 4, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants