V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  zhouyin  ›  全部回复第 4 页 / 共 47 页
回复总数  933
1  2  3  4  5  6  7  8  9  10 ... 47  
一开始我就是差不多你这样写的 没想到速度没提升 所以改成那样 以为 write 那里有缓冲区

一字不换把你的代码 运行 结果 耗时 一分钟多 望 python 莫及

-bash-4.2# time node a.js
finished

real 1m3.579s
user 1m4.103s
sys 0m2.478s
@henbf
我不是 nodejs 高手 我把 a.js 更新了 使用了输出流 但现在报堆溢出错误了 :

```bash
-bash-4.2# node a.js
(node:17974) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:17974) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(node:17974) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit

<--- Last few GCs --->

[17974:0x1c3dbf0] 40306 ms: Scavenge (reduce) 2046.8 (2082.1) -> 2046.5 (2082.6) MB, 44.4 / 0.0 ms (average mu = 0.342, current mu = 0.316) allocation failure
[17974:0x1c3dbf0] 40396 ms: Scavenge (reduce) 2047.2 (2082.6) -> 2046.8 (2082.8) MB, 31.1 / 0.0 ms (average mu = 0.342, current mu = 0.316) allocation failure


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x7fcfb6136908 node::Abort() [/lib64/libnode.so.93]
2: 0x7fcfb6024451 [/lib64/libnode.so.93]
3: 0x7fcfb732a552 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib64/libnode.so.93]
4: 0x7fcfb732a8e7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib64/libnode.so.93]
5: 0x7fcfb74ea305 [/lib64/libnode.so.93]
6: 0x7fcfb74ea3e5 [/lib64/libnode.so.93]
7: 0x7fcfb74fe77c v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib64/libnode.so.93]
8: 0x7fcfb74ff0a1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib64/libnode.so.93]
9: 0x7fcfb7502269 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib64/libnode.so.93]
10: 0x7fcfb75022f7 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib64/libnode.so.93]
11: 0x7fcfb74c27d0 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/lib64/libnode.so.93]
12: 0x7fcfb74badb4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/lib64/libnode.so.93]
13: 0x7fcfb74bcbdf v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString(int, v8::internal::AllocationType) [/lib64/libnode.so.93]
14: 0x7fcfb74c4d5d v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [/lib64/libnode.so.93]
15: 0x7fcfb733d59d v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/lib64/libnode.so.93]
16: 0x7fcfb6215390 node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [/lib64/libnode.so.93]
17: 0x7fcfb6123ef3 [/lib64/libnode.so.93]
18: 0x7fcfb71ba3cc [/lib64/libnode.so.93]
Aborted
```
@gainsurier
还有 nodejs c++实现 没 python 做得好
@gainsurier
python 和 php ruby 不就是 c 实现的么 只是 python 实现得好
代码传不上来

看这里

https://cowtransfer.com/s/f0a48d2009fd4f
@meitounaoba
上限多少呢
@xieren58
25k/月很不错? 感觉技术蛮难的
5 天前
回复了 unt 创建的主题 数据库 过来人说说, postgresql 和 mysql 究竟怎么选
@gimp
@knightdf
@FrankFang128
@shiny
@encro
@ymmud
@0x1001
@wangtian2020
@dbskcnc
@defunct9
@billbob
@murmur
@billbob
@Leviathann
@AmaQuinton
@Geon97
@AdamMing
@zoharSoul
@momo2789
@mmmhhhddd
@wencan
@donaldturinglee
@ala2008
@dmanbu

诸位 真心用过 pg 和 mysql 的说说 mysql 有 memory 引擎 postgresql 最新版有没有?
6 天前
回复了 unt 创建的主题 数据库 过来人说说, postgresql 和 mysql 究竟怎么选
没人说 pg 的 sql 语句更严格吗 需要把 groupby 后面的字段都出现在 select 子句里
mysql 我一直以来都把 sql_mode 设为空
6 天前
回复了 unt 创建的主题 数据库 过来人说说, postgresql 和 mysql 究竟怎么选
@mmmhhhddd
你的什么大数据项目 产生多少钱了?
技术要求很高 薪资能不能透露呢
6 天前
回复了 easynote 创建的主题 杭州 2025 年杭州买房有啥建议吗
怎么没人说未科无生活气息?
@DDStrange
@smile2wild
@szkoda
4 万人民币以内一月?
@murmur
华为外包待遇咋样
@BeforeTooLate
crud 工作都找不到?
@BeforeTooLate
普通工作都找不到?
8 天前
回复了 ne6rd 创建的主题 职场话题 中年想去日本,求指点迷津
@liukanshan
20-30 万日元?
9 天前
回复了 bboring 创建的主题 旅行 返程了,还是自己的「狗窝」舒服~
@forgottencoast
你们一定分开烧饭吧 最好前门后门分开
天下还有喜欢测试的 双倍的工作量
1  2  3  4  5  6  7  8  9  10 ... 47  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5646 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms · UTC 01:34 · PVG 09:34 · LAX 17:34 · JFK 20:34
Developed with CodeLauncher
♥ Do have faith in what you're doing.