Closed orange-jacky closed 6 years ago
Hi @orange-jacky
This is most likely an application issue, not mgo - please post a reproducible example if you think it's definitely mgo.
Either way, readElemTo
is the method that allocates the types to store the document fields - it's always going to allocate extensively - it has to do so both for your documents, and the mongodb protocol messages / any communication with mongo. I guess you're using pprof in alloc_space
mode which would show this.
Dom
hi, domodwyer i post the my project and a record, you can reproduce it env 1.go1.10.3 2.Linux 2.6.32-642.13.1.el6.x86_64 3.mongo3.2
you can download fpr_index.zip, unzip it into $GOPATH/huoli, go install huoli/fpr_index compile it. you can download record.txt which has a record, you can dump to 200000 records with it than you should configure the fpr_index/conf/cf.json, change mongo host info. execute " ps -ef | grep fpr " get fpr pid, and top -p pid you will see that fpr_index use lots of memory. cd $GOPATH/huoli/fpr_index ,to open cpu and memory profile, you should execute echo "on" > conf/profile_switch.txt, after a while, to close cpu and memory profile , you should excute echo "off" > conf/profile_switch.txt, and you will see memory and cpu profile file in logs_profile.
hi, i use globalsign/mgo pakage in my project, and i want read a 110MB datas that it's 200000 records. After using runtime/pprof, i find that 110MB datas save in a map, it's size 110MB, but iter use about 600MB+; "github.com/globalsign/mgo/bson.(*decoder).readElemTo" use about 600MB+. can you tell me how to optimize it hope your reply