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

打开CloudDrive 挂载的txt文件速度非常慢甚至会卡死 #751

Open
vvyoko opened this issue Jan 21, 2024 · 3 comments
Open

打开CloudDrive 挂载的txt文件速度非常慢甚至会卡死 #751

vvyoko opened this issue Jan 21, 2024 · 3 comments

Comments

@vvyoko
Copy link

vvyoko commented Jan 21, 2024

notepad2notepad3 打开clouddrive2挂载的txt非常非常慢甚至会卡死
打开一个不到1kb的文件需要耗时10秒+
但是vscode和Sublime Text, notepad++都没问题

然后用alist测试了下,上面所有软件打开txt都没问题...

我准备两边都反馈下,不太确定是谁的问题

notepad2

@zufuliu
Copy link
Owner

zufuliu commented Jan 21, 2024

Here is read file code:

notepad2/src/Edit.c

Lines 968 to 1041 in 226180b

bool EditLoadFile(LPWSTR pszFile, EditFileIOStatus *status) {
HANDLE hFile = CreateFile(pszFile,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
dwLastIOError = GetLastError();
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
LARGE_INTEGER fileSize;
fileSize.QuadPart = 0;
if (!GetFileSizeEx(hFile, &fileSize)) {
dwLastIOError = GetLastError();
CloseHandle(hFile);
return false;
}
// display real path name
PathGetRealPath(hFile, pszFile, pszFile);
// Check if a warning message should be displayed for large files
#if defined(_WIN64)
// less than 1/2 available physical memory:
// 1. Buffers we allocated below or when saving file, depends on encoding.
// 2. Scintilla's content buffer and style buffer, see CellBuffer class.
// The style buffer is disabled when using SCLEX_NULL (Text File, 2nd Text File, ANSI Art).
// i.e. when default scheme is Text File or 2nd Text File, memory required to load the file
// is about fileSize*2, buffers we allocated below can be reused by system to served
// as Scintilla's style buffer when calling SciCall_SetLexer() inside Style_SetLexer().
// 3. Extra memory when moving gaps on editing, it may require more than 2/3 physical memory.
// large file TODO: https://github.com/zufuliu/notepad2/issues/125
// [ ] [> 4 GiB] use SetFilePointerEx() and ReadFile()/WriteFile() to read/write file.
// [-] [> 2 GiB] fix encoding conversion with MultiByteToWideChar() and WideCharToMultiByte().
LONGLONG maxFileSize = INT64_C(4) << 30;
#else
// 2 GiB: ptrdiff_t / Sci_Position used in Scintilla
LONGLONG maxFileSize = INT64_C(2) << 30;
#endif
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
if (GlobalMemoryStatusEx(&statex)) {
const ULONGLONG maxMem = statex.ullTotalPhys/2U;
if (maxMem < (ULONGLONG)maxFileSize) {
maxFileSize = (LONGLONG)maxMem;
}
} else {
dwLastIOError = GetLastError();
}
if (fileSize.QuadPart > maxFileSize) {
CloseHandle(hFile);
status->bFileTooBig = true;
WCHAR tchDocSize[32];
WCHAR tchMaxSize[32];
WCHAR tchDocBytes[32];
WCHAR tchMaxBytes[32];
StrFormatByteSize(fileSize.QuadPart, tchDocSize, COUNTOF(tchDocSize));
StrFormatByteSize(maxFileSize, tchMaxSize, COUNTOF(tchMaxSize));
FormatNumber64(tchDocBytes, fileSize.QuadPart);
FormatNumber64(tchMaxBytes, maxFileSize);
MsgBoxWarn(MB_OK, IDS_WARNLOADBIGFILE, pszFile, tchDocSize, tchDocBytes, tchMaxSize, tchMaxBytes);
return false;
}
char *lpData = (char *)NP2HeapAlloc((SIZE_T)(fileSize.QuadPart) + NP2_ENCODING_DETECTION_PADDING);
DWORD cbData = 0;
const BOOL bReadSuccess = ReadFile(hFile, lpData, (DWORD)(fileSize.QuadPart), &cbData, NULL);
dwLastIOError = GetLastError();
CloseHandle(hFile);

@vvyoko
Copy link
Author

vvyoko commented Jan 22, 2024

CloudDrive2回复了
说让挂载成本地盘模式,怀疑是notepad2处理网络的问题
我挂成本地盘后正常了,至此我的问题已经解决了

另外反馈下,
我看了下它分成本地盘和网络盘两种模式
在本地盘的路径是普通的 X:\Aliyun\1\1.tx
在网络盘路径是这样的 \\CloudDirve\X\Aliyun\1\1.tx
出现问题的是网络路径

但是目前我也找不到其他的类似这样的网络路径,也就不测试了

@zufuliu
Copy link
Owner

zufuliu commented Jan 23, 2024

\\CloudDirve\X\Aliyun\1\1.tx is treated as Windows share (Samba) path.

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

No branches or pull requests

2 participants