这是我的问题的描述:
我想读取一个大的文件,大约6.3GB,所有内存使用readC中的系统调用,但发生错误.这是代码:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
int main(int argc, char* argv[]) {
int _fd = open(argv[1], O_RDONLY, (mode_t) 0400);
if (_fd == -1)
return 1;
off_t size = lseek(_fd, 0, SEEK_END);
printf("total size: %lld\n", size);
lseek(_fd, 0, SEEK_SET);
char *buffer = malloc(size);
assert(buffer);
off_t total = 0;
ssize_t ret = read(_fd, buffer, size);
if (ret != size) {
printf("read fail, %lld, reason:%s\n", …Run Code Online (Sandbox Code Playgroud) 代码行
\nnext += val;\nRun Code Online (Sandbox Code Playgroud)\n性能下降到 10 倍,我检查了 ASM 代码,而不是结果。
\n为什么这行代码会使性能下降 10 倍?
\n结果如下:
\n\xe2\x9e\x9c ~ clang-13 1.c -O3\n\xe2\x9e\x9c ~ ./a.out\nrand_read_1\nsum = 2624b18779c40, time = 0.19s\nrand_read_2\nsum = 2624b18779c40, time = 1.24s\nRun Code Online (Sandbox Code Playgroud)\nCPU:Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz
\n这是代码:
\n#include <stdio.h>\n#include <time.h>\n#include <stdint.h>\n#include <unistd.h>\n#include <string.h>\n#include <assert.h>\n#include <stdlib.h>\n\n#define CCR_MULTIPLY_64 6364136223846793005\n#define CCR_ADD_64 1\nstatic inline uint64_t my_rand64(uint64_t *r)\n{\n *r = *r * CCR_MULTIPLY_64 + CCR_ADD_64;\n return *r;\n}\n\n#define NUM 10000000UL\n\nuint64_t rand_read_1(uint64_t *ptr, uint64_t nr_words)\n{\n uint64_t i, next, …Run Code Online (Sandbox Code Playgroud) 我想打印文档时遇到打印机问题,打印机队列显示“后端失败”然后暂停。
我的电脑是mac os x,版本是sierra 10.12.6,打印机是Canon IR ADV4235,使用smb协议访问。我尝试了以下方法:
但仍然是同样的问题。
所以,我想找到具体的错误,我用关键字“backend”搜索了 /var/log 但没有相关结果。有人可以提供一些帮助吗?提前致谢。
更新:使用命令cupsctl --debug-logging?我收到了更多消息。以下错误消息似乎有帮助。
D [31/Jul/2017:13:47:44 +0800] [Job 25] PID 55276 (/usr/libexec/cups/backend/smb) crashed on signal 4.
...
D [31/Jul/2017:13:47:46 +0800] cupsdSetBusyState: newbusy="Printing jobs and dirty files", busy="Printing jobs and dirty files"
D [31/Jul/2017:13:47:46 +0800] [Job 25] PID 55275 (/Library/Printers/Canon/CUPS_Printer/Bins/capdftopdl) stopped with status 1.
I [31/Jul/2017:13:47:46 +0800] [Job 25] Backend returned status -4 (crashed)
D [31/Jul/2017:13:47:46 +0800] Discarding unused job-state-changed event...
I [31/Jul/2017:13:47:46 +0800] [Job 25] Printer …