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
23 changes: 22 additions & 1 deletion base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ See Hwloc.jl or CpuId.jl for extended information, including number of physical
"""
CPU_THREADS = 1 # for bootstrap, changed on startup

"""
Sys.CPU_NAME

The name of the host CPU as a string.
"""
CPU_NAME = "" # for bootstrap, changed on startup

"""
Sys.ARCH

Expand Down Expand Up @@ -188,6 +195,15 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j)
println(io)
end

"""
Sys.cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info())

Print a summary of information about each processor in `cpu` gathered from [`cpu_info](@ref). This is generally:
- Its index in the `cpu` vector
- The CPU model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps put this first since it is the first thing to show

- The CPU speed
- The amount of time spent in `user`, `nice`, `sys`, `idle`, and `irq` modes
"""
function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info())
model = cpu[1].model
first = 1
Expand All @@ -200,6 +216,11 @@ function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info())
_cpu_summary(io, cpu, first, length(cpu))
end

"""
Sys.cpu_info()

Gather information about all CPUs in the system through a syscall using LibUV.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libuv is usually in lowercase but I am not sure it is needed in the docstring at all.

We dont have any documentation about the type of struct getting returned CPUinfo, so there isn't really any useful thing you can do with the return value here. Arguably this should just not be exported (which is breaking).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we doc it for now then remove the export in the future?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Gather information about all CPUs in the system through a syscall using LibUV.
Gather information about the logical CPU cores in the system. This includes:
- The model name
- The clock speed
- The amount of time spent in `user`, `nice`, `sys`, `idle`, and `irq` modes

(and drop the corresponding list from Sys.cpu_summary)

"""
function cpu_info()
UVcpus = Ref{Ptr{UV_cpu_info_t}}()
count = Ref{Int32}()
Expand All @@ -215,7 +236,7 @@ end
"""
Sys.uptime()

Gets the current system uptime in seconds.
Get the current system uptime in seconds.
"""
function uptime()
uptime_ = Ref{Float64}()
Expand Down
2 changes: 2 additions & 0 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ Base.@elapsed
Base.@allocated
Base.EnvDict
Base.ENV
Base.Sys.cpu_summary
Base.Sys.cpu_info
Base.Sys.isunix
Base.Sys.isapple
Base.Sys.islinux
Expand Down
1 change: 1 addition & 0 deletions doc/src/base/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Base.DEPOT_PATH
Base.LOAD_PATH
Base.Sys.BINDIR
Base.Sys.CPU_THREADS
Base.Sys.CPU_NAME
Base.Sys.WORD_SIZE
Base.Sys.KERNEL
Base.Sys.ARCH
Expand Down