Skip to content

Commit 5d6c2b8

Browse files
committed
Update readme to better describe integration with upstream
1 parent 996bcbf commit 5d6c2b8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ cd java-profiler
3535

3636
The resulting artifact will be in `ddprof-lib/build/libs/ddprof-<version>.jar`
3737

38+
#### Gritty details
39+
To smoothen the absorption of the upstream changes, we are using parts of the upstream codebase in (mostly) vanilla form.
40+
41+
For this we have four new gradle tasks in `ddprof-lib/build.gradle`:
42+
- `cloneAsyncProfiler` - clones the upstream repository into `ddprof-lib/build/async-profiler` using the commit lock specified in `gradle/ap-lock.properties`
43+
- `copyUpstreamFiles` - copies the selected upstream source file into the `ddprof-lib/src/main/cpp-external` directory
44+
- `patchStackFrame` and `patchStackWalker` - patches the upstream files if it is unavoidable to eg. pass the asan checks
45+
46+
Since the upstream code might not be 100% compatible with the current version of the project, we need to provide adapters.
47+
The adapters are sharing the same file name as the upstream files but are suffixed with `_dd` (e.g. `arch_dd.h`).
48+
49+
In case we need to adapt a class from the upstream codebase, we put the adapter class into `ddprof` namespace to avoid
50+
conflicts with the upstream code. This allows us to use the upstream code as-is while still providing the necessary modifications for our use case.
51+
52+
See [ddprof-lib/src/main/cpp/stackWalker_dd.h](ddprof-lib/src/main/cpp/stackWalker_dd.h) for an example of how we adapt the upstream code to fit our needs.
53+
54+
An example of this is the `ddprof-lib/src/main/cpp-external/stack_frame.cpp` file which is a modified version of the upstream `stack_frame.cpp` file.
55+
3856
## Testing
3957

4058
### Unit Tests
@@ -128,18 +146,3 @@ DD_SERVICE=your-service DD_TRACE_DEBUG=true java -javaagent:./temp/dd-java-agent
128146

129147
For dd-trace-java you just need to set the `ddprof.jar` project property.
130148
Eg. you can run the gradle build like this - ./gradlew clean -Pddprof.jar=file://<path-to-artifact.jar> :dd-java-agent:shadowJar` - which will result in a custom `dd-java-agent.jar` build containing your test version of Java profiler.
131-
132-
## Working with upstream
133-
134-
Although this project still shares the git history with the upstream the code structure is different. This makes it dificult to reliably
135-
cherry-pick the upstream changes. To make this easier we have a script that will prepare the upstream repository
136-
and add it as 'cherry' remote to this repository.
137-
This way you can cherry-pick the changes from the upstream repository with (relative) ease.
138-
139-
```bash
140-
./utils/init_cherrypick_repo.sh # you need to run this only once
141-
142-
./utils/cherry.sh <commit>
143-
# ... resolve conflicts, if any
144-
./utils/cherry.sh --continue # to commit the resolved conflicts
145-
```

0 commit comments

Comments
 (0)