小编zha*_*tar的帖子

在x86_64上,大6GB文件的read()失败

这是我的问题的描述:

我想读取一个大的文件,大约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)

c linux file-io posix unbuffered

14
推荐指数
2
解决办法
696
查看次数

为什么一行代码性能会下降 10 倍?

代码行

\n
next += val;\n
Run 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\n
Run Code Online (Sandbox Code Playgroud)\n

CPU: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)

c performance x86 clang

3
推荐指数
1
解决办法
192
查看次数

如何在 mac os x 上找到打印机错误日志?

我想打印文档时遇到打印机问题,打印机队列显示“后端失败”然后暂停。

我的电脑是mac os x,版本是sierra 10.12.6,打印机是Canon IR ADV4235,使用smb协议访问。我尝试了以下方法:

  1. 从佳能网站下载最新的驱动程序,并重新安装驱动程序
  2. 移除旧打印机
  3. 添加新打印机

但仍然是同样的问题。

所以,我想找到具体的错误,我用关键字“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 …

printing macos logging

2
推荐指数
1
解决办法
5045
查看次数

标签 统计

c ×2

clang ×1

file-io ×1

linux ×1

logging ×1

macos ×1

performance ×1

posix ×1

printing ×1

unbuffered ×1

x86 ×1