I heard multiple times that putting gc.log on NFS volume is terrible idea because it might cause gc pauses to be longer. Is it still the case with current jdk (8u25)?
Asked
Active
Viewed 879 times
4
-
1I don't see why this would have changed. Making gc logging asynchronous would be bad for performance in the most common case ... where asynchrony isn't needed. If you really, really want to know then: 1) test it or 2) read the source code. – Stephen C Nov 22 '14 at 00:39
1 Answers
8
So I checked - it's not asynchronous and uses regular fopen/fwrite. Relevant code from jdk8u:
gcLogFileStream::gcLogFileStream(const char* file_name) {
_cur_file_num = 0;
_bytes_written = 0L;
_file_name = make_log_name(file_name, NULL);
// gc log file rotation
if (UseGCLogFileRotation && NumberOfGCLogFiles > 1) {
char tempbuf[FILENAMEBUFLEN];
jio_snprintf(tempbuf, sizeof(tempbuf), "%s.%d" CURRENTAPPX, _file_name, _cur_file_num);
_file = fopen(tempbuf, "w");
} else {
_file = fopen(_file_name, "w");
}
if (_file != NULL) {
_need_close = true;
dump_loggc_header();
} else {
warning("Cannot open file %s due to %s\n", _file_name, strerror(errno));
_need_close = false;
}
}
void gcLogFileStream::write(const char* s, size_t len) {
if (_file != NULL) {
size_t count = fwrite(s, 1, len, _file);
_bytes_written += count;
}
update_position(s, len);
}

mabn
- 2,473
- 1
- 26
- 47