Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ build:
deploy_to_reliability_env:
stage: deploy
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
when: always
- if: '$FORCE_TRIGGER == "true"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:
project: DataDog/apm-reliability/datadog-reliability-env
branch: $DOWNSTREAM_REL_BRANCH
Expand Down
139 changes: 133 additions & 6 deletions profiling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ crate-type = ["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ahash = { version = "0.8" }
anyhow = { version = "1.0" }
bumpalo = { version = "3.12", features = ["collections"] }
cfg-if = { version = "1.0" }
crossbeam-channel = { version = "0.5", default-features = false, features = ["std"] }
cpu-time = { version = "1.0" }
crossbeam-channel = { version = "0.5", default-features = false, features = ["std"] }
datadog-profiling = { git = "https://github.com/DataDog/libdatadog", tag = "v2.0.0" }
env_logger = { version = "0.9.3" }
env_logger = { version = "0.10" }
indexmap = { version = "1.8" }
lazy_static = { version = "1.4" }
libc = "0.2"
# TRACE set to max to support runtime configuration.
log = { version = "0.4", features = ["max_level_trace", "release_max_level_trace"]}
once_cell = { version = "1.12" }
uuid = { version = "1.0", features = ["v4"] }
rand = { version = "0.8.5" }
rand_distr = { version = "0.4.3" }
self_cell = { version = "0.10" }
uuid = { version = "1.0", features = ["v4"] }

[features]
default = ["allocation_profiling"]
Expand Down
28 changes: 28 additions & 0 deletions profiling/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ extern "C" {
/// strings will be converted into a string view to a static empty string
/// (single byte of null, len of 0).
pub fn ddog_php_prof_zend_string_view(zstr: Option<&mut zend_string>) -> zai_string_view;

/// Registers the run_time_cache slot with the engine. Must be done in
/// module init or extension startup.
pub fn ddog_php_prof_function_run_time_cache_init(module_name: *const c_char);

/// Gets the address of a function's run_time_cache slot. May return None
/// if it detects incomplete initialization, which is always a bug but
/// none-the-less has been seen in the wild. It may also return None if
/// the run_time_cache is not available on this function type.
pub fn ddog_php_prof_function_run_time_cache(func: &zend_function) -> Option<&mut [usize; 2]>;
}

#[cfg(php_preload)]
Expand Down Expand Up @@ -498,3 +508,21 @@ pub struct ZaiConfigMemoizedEntry {
) -> c_int,
>,
}

#[cfg(test)]
mod tests {

// If this fails, then ddog_php_prof_function_run_time_cache needs to be
// adjusted accordingly.
#[test]
fn test_sizeof_fixed_size_slice_is_same_as_pointer() {
assert_eq!(
std::mem::size_of::<&[usize; 2]>(),
std::mem::size_of::<*mut usize>()
);
assert_eq!(
std::mem::align_of::<&[usize; 2]>(),
std::mem::align_of::<*mut usize>()
);
}
}
Loading