stability: "GO in use" and "GO Sys" is too high
here is my table's schema info,
create table FC_word(
IdeaId int,
UnitId int,
PlanId int,
UserId int,
Iflag int,
Ilong int,
IdeaStat1 int,
IdeaStat2 int,
IdeaStat3 int,
IdeaStat4 int,
IdeaStat5 int,
IdeaStat6 int,
Touch int,
ModUid int,
ModTime timestamp,
Isdel int,
ChkUid int,
ChkTime timestamp,
RsnId int,
Reason varchar(256),
DeviceOpt int,
Temperature int
);
here is my insert sql: INSERT INTO fc_word VALUES (4199338396,807952347,20737795,6819880,1,1,4,0,0,4,0,0,7,6819880,'2015-03-27 14:28:43'::timestamp,0,NULL,'2015-03-27 14:34:13'::timestamp,32768,NULL,0,0), (4199338399,807952350,20737795,6819880,1,1,4,0,0,4,0,0,7,6819880,'2015-03-27 14:28:43'::timestamp,0,NULL,'2015-03-27 14:34:13'::timestamp,32768,NULL,0,3);
I insert 200 values like above in a insert statement.
after I write about 200 million rows, the memory usage is like behind,


the QPS is like this:


the memory usage seems too high. the QPS seems too low.
@tamird Can we make a load generator for this schema and try to reproduce the problem? Or are we seeing similar problems in our beta cluster tests?
We have not been seeing similar problems. Sometimes the "go in use" value will spike quickly to many gigs and kill the process, but when the cluster is stable "go in use" is around 100MB and "go sys" is around 400MB.
Can you download http://host:port/debug/pprof/heap?debug=1 from one of these nodes and attach it here (and tell us which binary version you're running)?
@bdarnell the binary version I use is beta-20160512. how can I get http://host:port/debug/pprof/heap?debug=1, should I add some code in main function?
http://host:port refers to the cockroach server's http port (8080 by default). So you could do curl http://localhost:8080/debug/pprof/heap?debug=1 > heap.profile
here is my profile. heap.profile.zip
According to that heap profile, Go was only using 81MB. Was this profile taken at a time when "go in use" was reporting several GB? (you can generate this report yourself with go tool pprof ./cockroach heap.profile, then type top at the command prompt)
(pprof) top
73.52MB of 81.06MB total (90.70%)
Dropped 994 nodes (cum <= 0.41MB)
Showing top 10 nodes out of 127 (cum >= 1.03MB)
flat flat% sum% cum cum%
33.50MB 41.33% 41.33% 34.50MB 42.56% github.com/cockroachdb/cockroach/sql/parser.(*scanner).scanNumber
13MB 16.04% 57.37% 20.50MB 25.29% github.com/cockroachdb/cockroach/storage.(*TimestampCache).Add.func1
12MB 14.81% 72.18% 47.51MB 58.60% github.com/cockroachdb/cockroach/sql/parser.(*sqlParserImpl).Parse
7.50MB 9.25% 81.43% 7.50MB 9.25% github.com/cockroachdb/cockroach/util/interval.(*Node).insert
2.06MB 2.55% 83.97% 2.06MB 2.55% github.com/cockroachdb/cockroach/sql/pgwire.(*readBuffer).readUntypedMsg
1.13MB 1.40% 85.37% 1.13MB 1.40% github.com/cockroachdb/cockroach/client.(*Batch).appendReqs
1.10MB 1.35% 86.72% 2.81MB 3.46% github.com/cockroachdb/cockroach/client.(*Txn).send
1.10MB 1.35% 88.07% 3.90MB 4.81% github.com/cockroachdb/cockroach/client.sendAndFill
1.10MB 1.35% 89.42% 1.10MB 1.35% github.com/cockroachdb/cockroach/kv.truncate
1.03MB 1.27% 90.70% 1.03MB 1.27% github.com/codahale/hdrhistogram.New
It looks like your queries may be very large; try inserting fewer rows at a time. Other than that, there's nothing unusual in this profile.
@bdarnell thanks。I will try it again.
this photo is a new runtime memory stats.

here is the heap stats:
[email protected]:~$ go tool pprof http://localhost:8080/debug/pprof/heap
Fetching profile from http://localhost:8080/debug/pprof/heap
Saved profile in /root/pprof/pprof.localhost:8080.inuse_objects.inuse_space.010.pb.gz
Entering interactive mode (type "help" for commands)
(pprof) top
214.18MB of 225.91MB total (94.81%)
Dropped 1084 nodes (cum <= 1.13MB)
Showing top 10 nodes out of 106 (cum >= 1.50MB)
flat flat% sum% cum cum%
99.01MB 43.83% 43.83% 107.01MB 47.37% github.com/cockroachdb/cockroach/sql/parser.(*scanner).scanNumber
49.01MB 21.70% 65.52% 159.02MB 70.39% github.com/cockroachdb/cockroach/sql/parser.(*sqlParserImpl).Parse
14.50MB 6.42% 71.94% 26MB 11.51% github.com/cockroachdb/cockroach/storage.(*TimestampCache).Add.func1
13.84MB 6.12% 78.07% 13.84MB 6.12% github.com/cockroachdb/cockroach/storage.(*CommandQueue).add
11.50MB 5.09% 83.16% 11.50MB 5.09% github.com/cockroachdb/cockroach/util/interval.(*Node).insert
10.81MB 4.79% 87.95% 10.81MB 4.79% github.com/cockroachdb/cockroach/sql/pgwire.(*readBuffer).readUntypedMsg
8MB 3.54% 91.49% 8MB 3.54% go/constant.MakeFromLiteral
3MB 1.33% 92.81% 3MB 1.33% github.com/cockroachdb/cockroach/sql/parser.(*scanner).scanString
3MB 1.33% 94.14% 3MB 1.33% github.com/cockroachdb/cockroach/roachpb.(*Span).Unmarshal
1.50MB 0.67% 94.81% 1.50MB 0.67% github.com/cockroachdb/cockroach/storage.(*CommandQueue).getWait
(pprof)
the photo is not clear.

after running a log time, my cluster is stable with that stat.
If it's stable, then that looks fairly normal - the Go memory in use is reasonable relative to the total process size. It could be improved (that's a lot of memory to spend on parsed numbers), but I'm not seeing that obviously needs fixing.
@bdarnell today I execute a sql like this 'create index USER_ID on fc_word(UserId);' . the memory usage is a little too high.
the heap status is,
(pprof) top
351.42MB of 368.60MB total (95.34%)
Dropped 1319 nodes (cum <= 1.84MB)
Showing top 10 nodes out of 92 (cum >= 3.01MB)
flat flat% sum% cum cum%
159.51MB 43.28% 43.28% 167.51MB 45.45% github.com/cockroachdb/cockroach/sql/parser.(*scanner).scanNumber
70.52MB 19.13% 62.41% 246.04MB 66.75% github.com/cockroachdb/cockroach/sql/parser.(*sqlParserImpl).Parse
41.01MB 11.12% 73.53% 72.51MB 19.67% github.com/cockroachdb/cockroach/storage.(*TimestampCache).Add.func1
31.50MB 8.55% 82.08% 31.50MB 8.55% github.com/cockroachdb/cockroach/util/interval.(*Node).insert
11.83MB 3.21% 85.29% 11.83MB 3.21% github.com/cockroachdb/cockroach/sql/pgwire.(*readBuffer).readUntypedMsg
11.04MB 2.99% 88.28% 11.04MB 2.99% github.com/cockroachdb/cockroach/storage.(*CommandQueue).add
8MB 2.17% 90.45% 8MB 2.17% github.com/cockroachdb/cockroach/sql/parser.(*scanner).scanString
8MB 2.17% 92.62% 8MB 2.17% go/constant.MakeFromLiteral
7MB 1.90% 94.52% 7MB 1.90% github.com/cockroachdb/cockroach/roachpb.(*Span).Unmarshal
3.01MB 0.82% 95.34% 3.01MB 0.82% github.com/cockroachdb/cockroach/storage.(*CommandQueue).getWait
I'm a little confused, is this status normal?
Quite a big discrepancy between what pprof is reporting (368 MB) and the Go in Use stat (2.2 Gib). I wonder what is causing that. Oh, perhaps the heap profiling numbers shown in pprof aren't scaled by the sampling rate. Regardless, I'm surprised to see so much memory tied up in SQL parser structures. Besides the addition of the index, is there other load being sent to the system?
The resident set size (RSS) is huge. @a6802739 what sort of system are you running on? Did you configure the --cache-size setting on the command line or are you relying on the auto-selected value?
@petermattis, except the addition of the index, there is no other load. I didn't configure --cache-size, it's default value. my server's real memory is 48G.
I don't think the difference is the pprof sampling rate - the ratio between 368MB and 2.2GiB is 6:1, which wouldn't make sense for heap sampling. Note that "Go in use" in our UI maps to MemStats.Alloc, not MemStats.HeapInUse. The docs aren't very clear about what's included in each these stats. One difference is goroutine stacks, but I can see part of the goroutine graph in your screenshots and it looks stable. Maybe it's the (non-garbage-collectable) data allocated by go to pass into c++?
If all load besides the schema change has stopped, you shouldn't be seeing so many parsed numbers in memory (schema changes don't go through the text parser). Are we leaking/caching those somewhere we shouldn't? If your client is using prepared statements, are you cleaning them up?
@bdarnell I can't quite understand If your client is using prepared statements, are you cleaning them up?, I execute this command in cockroachdb's shell.
My question was about the INSERT commands, not the CREATE INDEX. Are you piping those insert statements as strings into cockroach sql?
@bdarnell , the client will wait the insert statement finish and then execute next command. my client which executes the batch insert has already stopped, so i doubt this problem has matter with the insert statement.
Most of the memory usage comes from (*sqlParserImpl).Parse, which would be used mainly for the insert statements. If that data is staying in memory after the insert statements have stopped, then that should be a clue about where the bug is. We have something that is holding on to the results of query parsing longer than necessary.
Unassigning myself since I'm not actively looking at this.