Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion external/polar_monitor/procstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <linux/limits.h>
#include <sys/times.h>

typedef enum PROCARGTYPE
Expand Down
27 changes: 22 additions & 5 deletions src/backend/libpq/polar_network_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

#include "postgres.h"

#ifdef __linux__
#include <linux/sockios.h>
#endif
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -210,22 +212,25 @@ polar_network_stat_timer(void)
static void
polar_network_get_tcpinfo(void)
{
#ifdef __linux__
struct tcp_info info;
int length = sizeof(struct tcp_info);
struct timeval now;
int ret;
int index;
int length = sizeof(struct tcp_info);
#endif

if (!polar_network_stat_array)
return;

if (!MyProcPort)
return;

#ifdef __linux__
ret = getsockopt(MyProcPort->sock, SOL_TCP, TCP_INFO, (void *) &info, (socklen_t *) &length);
if (ret == 0)
{
struct timeval now;
int index = POLAR_NET_STAT_BACKEND_INDEX();

index = POLAR_NET_STAT_BACKEND_INDEX();
if (index < 0)
return;

Expand All @@ -238,6 +243,9 @@ polar_network_get_tcpinfo(void)
polar_network_stat_array[index].tcpinfo_update_time = now.tv_sec;
last_network_tcpinfo_update_time = now.tv_sec;
}
#else
/* TCP_INFO with SOL_TCP are Linux-specific, skip updating tcpinfo */
#endif
}

/*
Expand All @@ -246,9 +254,11 @@ polar_network_get_tcpinfo(void)
static void
polar_network_get_qlen(void)
{
#ifdef __linux__
int queue_len;
int index;
int ret;
#endif
int index;

if (!polar_network_stat_array)
return;
Expand All @@ -260,11 +270,18 @@ polar_network_get_qlen(void)
if (index < 0)
return;

#ifdef __linux__

ret = ioctl(MyProcPort->sock, SIOCOUTQ, &queue_len);
if (ret == 0)
polar_network_stat_array[index].sendq = queue_len;

ret = ioctl(MyProcPort->sock, SIOCINQ, &queue_len);
if (ret == 0)
polar_network_stat_array[index].recvq = queue_len;
#else
/* SIOCOUTQ/SIOCINQ are Linux-specific, set values to 0 */
polar_network_stat_array[index].sendq = 0;
polar_network_stat_array[index].recvq = 0;
#endif
}
16 changes: 14 additions & 2 deletions src/backend/postmaster/syslogger.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

/* POLAR */
#include "storage/fd.h"
#include "storage/polar_fd.h"
#include "utils/builtins.h"

/*
Expand Down Expand Up @@ -2092,9 +2093,20 @@ polar_drop_log_page_cache(const char *filename)
{
ereport(LOG,
(errmsg("the old log file doesn't exist")));

/* no need to go further */
return;
}
ret = posix_fadvise(last_log_fd, 0, 0, POSIX_FADV_DONTNEED);
/* return zero means success */
/*
* on platforms that support posix_fadvise, advise the kernel to drop
* cached pages for the old log file. Otherwise, skip silently.
*/
#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
ret = polar_posix_fadvise(last_log_fd, 0, 0, POSIX_FADV_DONTNEED);
#else
ret = 0;
#endif

if (ret != 0)
{
ereport(LOG,
Expand Down
4 changes: 4 additions & 0 deletions src/backend/storage/file/polar_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ vfs_mgr polar_vfs[] =
.vfs_fsync = pg_fsync,
.vfs_unlink = unlink,
.vfs_rename = rename,
#ifdef HAVE_POSIX_FALLOCATE
.vfs_posix_fallocate = posix_fallocate,
#else
.vfs_posix_fallocate = NULL,
#endif
#ifdef __linux__
.vfs_fallocate = fallocate,
#else
Expand Down
4 changes: 4 additions & 0 deletions src/polar_vfs/polar_bufferio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ const vfs_mgr polar_vfs_bio =
#endif
.vfs_unlink = unlink,
.vfs_rename = rename,
#ifdef HAVE_POSIX_FALLOCATE
.vfs_posix_fallocate = posix_fallocate,
#else
.vfs_posix_fallocate = NULL,
#endif
#ifdef __linux__
.vfs_fallocate = fallocate,
#else
Expand Down
4 changes: 4 additions & 0 deletions src/polar_vfs/polar_directio.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const vfs_mgr polar_vfs_dio =
.vfs_fsync = polar_directio_fsync,
.vfs_unlink = unlink,
.vfs_rename = rename,
#ifdef HAVE_POSIX_FALLOCATE
.vfs_posix_fallocate = posix_fallocate,
#else
.vfs_posix_fallocate = NULL,
#endif
#ifdef __linux__
.vfs_fallocate = fallocate,
#else
Expand Down
4 changes: 4 additions & 0 deletions src/polar_vfs/polar_vfs_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ vfs_mgr polar_vfs[] =
.vfs_fsync = fsync,
.vfs_unlink = unlink,
.vfs_rename = rename,
#ifdef HAVE_POSIX_FALLOCATE
.vfs_posix_fallocate = posix_fallocate,
#else
.vfs_posix_fallocate = NULL,
#endif
#ifdef __linux__
.vfs_fallocate = fallocate,
#else
Expand Down
Loading