Recursive search on a linux system (1 thread) from root including subdirectories causes 8.4 GB Ram and counting
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
The following code:
<?php
/**
* @throws DirectoryCreateException
* @throws Exception
*/
public function search($flags, $options): void
{
$object = $this->object();
$data = new Data($object->data());
if(!property_exists($options, 'name')){
throw new Exception('Option -name not set');
}
if(!property_exists($options, 'directory')){
throw new Exception('Option -directory not set');
}
$dir = new Dir();
$list = $dir->read($options->directory, true);
foreach($list as $file){
if($file->name === $options->name){
breakpoint('match');
}
}
breakpoint($list);
}
Resulted in this output:
15625 root 20 0 9139760 8.5g 2304 R 99.7 55.0 15:11.97 php
15625 root 20 0 13.3g 13.0g 2304 R 100.0 83.9 24:48.36 php
But I expected this output instead:
15625 root 20 0 9139760 1.5g 2304 R 99.7 3.0 15:11.97 php
What i meant is this:
I keep a list of all files on the system and searches for a match.
I can create a search from root directory and go 1 subdirectory at a time but my opinion is that searching on a root device should work like a charm without complicating stuff too much...
PHP Version
PHP 8.4.12 (cli) (built: Sep 7 2025 14:06:59) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.12, Copyright (c) Zend Technologies
with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
Operating System
Debian bookworm
CLI:
app raxon/basic file search -directory=/ -name=Snow.js
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với CLI command được cung cấp, PHP 8.4.12 và môi trường Debian bookworm, sau đó tái hiện mức tăng bộ nhớ trong khi theo dõi lệnh gọi Dir::read của ứng dụng. Xác định xem hành vi này xuất phát từ PHP hay mã ứng dụng, đồng thời ghi lại một trường hợp tái hiện tối thiểu và hành vi bộ nhớ dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- debian, linux, php
- Lĩnh vực
- cli, operating-systems
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100