Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Very high memory usage when running under sudo in Linux

未关闭
#180 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
linux, python

调研方向

从最小化的 Python 复现程序开始,比较正常运行和在 sudo 下运行时 softioc.iocInit 前后的内存读数。调查 softioc.iocInit 所到达的初始化路径;当 sudo 运行不再显示约 950 MB 的增长,同时保持正常的 IOC 启动时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

Hi all,

It seems that creating and initializing an IOC takes up a crazy high amount of memory when ran under sudo. This is not the case when ran as user. Here is a minimal example to demonstrate:

import psutil
from softioc import softioc, builder, asyncio_dispatcher

def print_memory_usage(loc: str):
    print(f"{loc:32s}: {psutil.Process().memory_info().rss:,}")

print_memory_usage("Before PV")
pv = builder.longOut("myVariable")

print_memory_usage("Before loadDatabase")
builder.LoadDatabase()

print_memory_usage("Before dispatcher")
dispatcher = asyncio_dispatcher.AsyncioDispatcher()
print_memory_usage("Before iocInit")
softioc.iocInit(dispatcher)

print_memory_usage("Before start")
softioc.interactive_ioc()

Output when ran as user:

INFO: PVXS QSRV2 is loaded, permitted, and ENABLED.
2025-01-16T13:55:56.327190606 WARN pvxs.tcp.setup Server unable to bind port 5075, falling back to [::]:37275
Before PV                       : 85,139,456
Before loadDatabase             : 85,139,456
Before dispatcher               : 85,139,456
Before iocInit                  : 87,236,608
Starting iocInit
############################################################################
## EPICS 7.0.7.1-DEV
## Rev. 7.0.7.99.1.1
## Rev. Date 7.0.7.99.1.1
############################################################################
cas WARNING: Configured TCP port was unavailable.
cas WARNING: Using dynamically assigned TCP port 43649,
cas WARNING: but now two or more servers share the same UDP port.
cas WARNING: Depending on your IP kernel this server may not be
cas WARNING: reachable with UDP unicast (a host's IP in EPICS_CA_ADDR_LIST)
iocRun: All initialization complete
Before start                    : 89,600,000
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>

Output when ran as sudo:

INFO: PVXS QSRV2 is loaded, permitted, and ENABLED.
2025-01-16T13:56:32.146488207 WARN pvxs.tcp.setup Server unable to bind port 5075, falling back to [::]:39775
Before PV                       : 85,114,880
Before loadDatabase             : 85,114,880
Before dispatcher               : 85,114,880
Before iocInit                  : 87,212,032
Starting iocInit
############################################################################
## EPICS 7.0.7.1-DEV
## Rev. 7.0.7.99.1.1
## Rev. Date 7.0.7.99.1.1
############################################################################
cas WARNING: Configured TCP port was unavailable.
cas WARNING: Using dynamically assigned TCP port 37929,
cas WARNING: but now two or more servers share the same UDP port.
cas WARNING: Depending on your IP kernel this server may not be
cas WARNING: reachable with UDP unicast (a host's IP in EPICS_CA_ADDR_LIST)
iocRun: All initialization complete
Before start                    : 950,546,432
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>

As you can see, the issue seems to happen in softioc.iocInit. Packages used to test (on Ubuntu):

softioc           4.5.0
psutil            6.1.1

This issue occurs both on Ubuntu and NixOS.

主要语言
Python
星标
47
派生
15
平均合并
1 天 18 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DiamondLightSource/pythonSoftIOC 的其他 Issue

查看 DiamondLightSource/pythonSoftIOC 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。