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

Condition where backtrace buffer for profiling is full #35870

Closed
kimikage opened this issue May 13, 2020 · 2 comments · Fixed by #36006
Closed

Condition where backtrace buffer for profiling is full #35870

kimikage opened this issue May 13, 2020 · 2 comments · Fixed by #36006

Comments

@kimikage
Copy link
Contributor

kimikage commented May 13, 2020

On Linux, the number of stored instruction pointers will be less than the specified maximum number.

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

julia> using Profile

julia> Profile.init(n = 100)

julia> Profile.clear()

julia> @profile rand(Float64, 100, 100);

julia> length(Profile.fetch())
99

In fact, the source code specifies that. However, I don't understand the meaning of the -1. The null sentinels are counted properly.

julia/src/signals-unix.c

Lines 700 to 706 in f12cde0

// Mark the end of this block with 0
bt_data_prof[bt_size_cur++].uintptr = 0;
}
if (bt_size_cur >= bt_size_max - 1) {
// Buffer full: Delete the timer
jl_profile_stop_timer();
}

Although the behavior is safer in terms of memory access, the warning below is not displayed correctly.

function fetch()
len = len_data()
maxlen = maxlen_data()
if (len == maxlen)
@warn """The profile data buffer is full; profiling probably terminated
before your program finished. To profile for longer runs, call
`Profile.init()` with a larger buffer and/or larger delay."""
end

I'm still studying how profiling works, so I am not confident in making a PR for this issue.

@kimikage kimikage changed the title Strange termination condition in profiling on Linux Condition where backtrace buffer for profiling is full May 21, 2020
@kimikage
Copy link
Contributor Author

Even if the last one stack is free, there is no point in filling it because it is used for the sentinel.

@kimikage
Copy link
Contributor Author

However, we may need not only "1" but also JL_BT_MAX_ENTRY_SIZE of free space. If there is not enough room, the end of the buffer will be filled with the sentinels. This isn't dangerous, but I don't think it is the desired behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant