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
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,48 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

include(CheckCXXCompilerFlag)

set(AVX_SUPPORTED FALSE)
set(AVX_COMPILER_FLAG "")

# Prioritize AVX2 as it's more capable than AVX1.
# Common flags for AVX2: -march=haswell (for Intel), -mavx2 (generic)
CHECK_CXX_COMPILER_FLAG("-march=haswell" CXX_SUPPORTS_HASWELL)
CHECK_CXX_COMPILER_FLAG("-mavx2" CXX_SUPPORTS_AVX2)

if(CXX_SUPPORTS_HASWELL)
set(AVX_SUPPORTED TRUE)
set(AVX_COMPILER_FLAG "-march=haswell")
message(STATUS "AVX2 (Haswell) support detected. Adding compiler flag: ${AVX_COMPILER_FLAG}")
elseif(CXX_SUPPORTS_AVX2)
set(AVX_SUPPORTED TRUE)
set(AVX_COMPILER_FLAG "-mavx2")
message(STATUS "Generic AVX2 support detected. Adding compiler flag: ${AVX_COMPILER_FLAG}")
else()
# Common flags for AVX1: -march=sandybridge (for Intel), -mavx (generic)
CHECK_CXX_COMPILER_FLAG("-march=sandybridge" CXX_SUPPORTS_SANDYBRIDGE)
CHECK_CXX_COMPILER_FLAG("-mavx" CXX_SUPPORTS_AVX)

if(CXX_SUPPORTS_SANDYBRIDGE)
set(AVX_SUPPORTED TRUE)
set(AVX_COMPILER_FLAG "-march=sandybridge")
message(STATUS "AVX1 (Sandy Bridge) support detected. Adding compiler flag: ${AVX_COMPILER_FLAG}")
elseif(CXX_SUPPORTS_AVX)
set(AVX_SUPPORTED TRUE)
set(AVX_COMPILER_FLAG "-mavx")
message(STATUS "Generic AVX1 support detected. Adding compiler flag: ${AVX_COMPILER_FLAG}")
else()
message(STATUS "Neither AVX1 nor AVX2 support detected. No specific AVX compiler flags added.")
endif()
endif()

if(AVX_SUPPORTED)
add_compile_options(${AVX_COMPILER_FLAG})
else()
message(STATUS "Building without specific AVX optimizations.")
endif()

add_subdirectory(src)

# install the man page
Expand Down
50 changes: 25 additions & 25 deletions src/details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ Lookup *Sockets::lookup = nullptr;

TableField *Sockets::fields()
{
static QList< TableField > fields( { { tr( "Fd" ), 5, 8, Qt::AlignRight, tr( "File descriptor" ) }
, { tr( "Proto" ), 4, 8, Qt::AlignLeft, tr( "Protocol (TCP or UDP)" ) }
, { tr( "Recv-Q" ), 9, 8, Qt::AlignRight, tr( "Bytes in receive queue" ) }
, { tr( "Send-Q" ), 9, 8, Qt::AlignRight, tr( "Bytes in send queue" ) }
, { tr( "Local Addr" ), -1, 8, Qt::AlignLeft, tr( "Local IP address" ) }
, { tr( "Port" ), 6, 8, Qt::AlignLeft, tr( "Local port" ) }
, { tr( "Remote Addr" ), -1, 8, Qt::AlignLeft, tr( "Remote IP address" ) }
, { tr( "Port" ), 6, 8, Qt::AlignLeft, tr( "Remote port" ) }
, { tr( "State" ), 18, 8, Qt::AlignLeft, tr( "Connection state" ) } } );
static QList< TableField > fields( { { tr( "Fd" ), tr( "File descriptor" ), 5, 8, Qt::AlignRight }
, { tr( "Proto" ), tr( "Protocol (TCP or UDP)" ), 4, 8, Qt::AlignLeft }
, { tr( "Recv-Q" ), tr( "Bytes in receive queue" ), 9, 8, Qt::AlignRight }
, { tr( "Send-Q" ), tr( "Bytes in send queue" ), 9, 8, Qt::AlignRight }
, { tr( "Local Addr" ), tr( "Local IP address" ), -1, 8, Qt::AlignLeft }
, { tr( "Port" ), tr( "Local port" ), 6, 8, Qt::AlignLeft }
, { tr( "Remote Addr" ), tr( "Remote IP address" ), -1, 8, Qt::AlignLeft }
, { tr( "Port" ), tr( "Remote port" ), 6, 8, Qt::AlignLeft }
, { tr( "State" ), tr( "Connection state" ), 18, 8, Qt::AlignLeft } } );
return fields.data();
}

Expand Down Expand Up @@ -389,13 +389,13 @@ void Sockets::update_hostname(unsigned int) {}
#endif
TableField *Maps::fields()
{
static QList< TableField > fields( { { tr( "Address Range" ), -1, 8, Qt::AlignLeft, tr( "Mapped addresses (hex) )" ) }
, { tr( "Size" ), 8, 8, Qt::AlignRight, tr( "Kbytes mapped (dec)" ) }
, { tr( "Perm" ), 5, 8, Qt::AlignLeft, tr( "Permission flags" ) }
, { tr( "Offset" ), -1, 8, Qt::AlignRight, tr( "File offset at start of mapping (hex)" ) }
, { tr( "Device" ), 8, 8, Qt::AlignLeft, tr( "Major,Minor device numbers (dec)" ) }
, { tr( "Inode" ), 10, 8, Qt::AlignRight, tr( "Inode number (dec)" ) }
, { tr( "File" ), -9, 8, Qt::AlignLeft, tr( "File name (if available)" ) } } );
static QList< TableField > fields( { { tr( "Address Range" ), tr( "Mapped addresses (hex) )" ), -1, 8, Qt::AlignLeft }
, { tr( "Size" ), tr( "Kbytes mapped (dec)" ), 8, 8, Qt::AlignRight }
, { tr( "Perm" ), tr( "Permission flags" ), 5, 8, Qt::AlignLeft }
, { tr( "Offset" ), tr( "File offset at start of mapping (hex)" ), -1, 8, Qt::AlignRight }
, { tr( "Device" ), tr( "Major,Minor device numbers (dec)" ), 8, 8, Qt::AlignLeft }
, { tr( "Inode" ), tr( "Inode number (dec)" ), 10, 8, Qt::AlignRight }
, { tr( "File" ), tr( "File name (if available)" ), -9, 8, Qt::AlignLeft } } );
return fields.data();
}

Expand Down Expand Up @@ -459,7 +459,7 @@ QString Maps::text(int row, int col)
s.setNum(mi->inode);
break;
case FILENAME:
s = mi->filename;
s = QString(mi->filename);
if (!Qps::show_file_path)
{
int i = s.lastIndexOf('/');
Expand Down Expand Up @@ -492,11 +492,11 @@ bool Maps::refresh_maps() { return procinfo()->read_maps(); }

TableField *Files::fields()
{
static QList< TableField > fields( { { tr( "Fd" ), 5, 8, Qt::AlignRight, tr( "File descriptor" ) }
static QList< TableField > fields( { { tr( "Fd" ), tr( "File descriptor" ), 5, 8, Qt::AlignRight }
#ifdef LINUX
, { tr( "Mode" ), 3, 8, Qt::AlignLeft, tr( "Open mode" ) }
, { tr( "Mode" ), tr( "Open mode" ), 3, 8, Qt::AlignLeft }
#endif
, { tr( "Name" ), -1, 8, Qt::AlignLeft, tr( "File name (if available)" )} } );
, { tr( "Name" ), tr( "File name (if available)" ), -1, 8, Qt::AlignLeft } } );
return fields.data();
}

Expand Down Expand Up @@ -576,8 +576,8 @@ QString Files::text(int row, int col)

TableField *Environ::fields()
{
static QList< TableField > fields( { { tr( "Variable" ), -1, 8, Qt::AlignLeft, tr( "Variable name" ) }
, { tr( "Value" ), -1, 8, Qt::AlignLeft, tr( "Variable value" ) } } );
static QList< TableField > fields( { { tr( "Variable" ), tr( "Variable name" ), -1, 8, Qt::AlignLeft }
, { tr( "Value" ), tr( "Variable value" ), -1, 8, Qt::AlignLeft } } );
return fields.data();
}

Expand Down Expand Up @@ -624,9 +624,9 @@ void Environ::refresh()

TableField *AllFields::fields()
{
static QList< TableField > fields( { { tr( "Field" ), -1, 8, Qt::AlignLeft, tr( "Field name" ) }
, { tr( "Description" ), -1, 8, Qt::AlignLeft, tr( "Field description" ) }
, { tr( "Value" ), -1, 8, Qt::AlignLeft, tr( "Field value" ) } } );
static QList< TableField > fields( { { tr( "Field" ), tr( "Field name" ), -1, 8, Qt::AlignLeft }
, { tr( "Description" ), tr( "Field description" ), -1, 8, Qt::AlignLeft }
, { tr( "Value" ), tr( "Field value" ), -1, 8, Qt::AlignLeft } } );
return fields.data();
}

Expand Down
10 changes: 5 additions & 5 deletions src/details.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Sockets : public SimpleTable
QString text(int row, int col) override;

private:
enum
enum : unsigned char
{
FD,
PROTO,
Expand Down Expand Up @@ -143,7 +143,7 @@ class Maps : public SimpleTable
QString text(int row, int col) override;

private:
enum
enum : unsigned char
{
ADDRESS,
SIZE,
Expand Down Expand Up @@ -171,7 +171,7 @@ class Files : public SimpleTable
QString text(int row, int col) override;

private:
enum
enum : unsigned char
{
FILEDESC,
#ifdef LINUX
Expand All @@ -197,7 +197,7 @@ class Environ : public SimpleTable
QString text(int row, int col) override;

private:
enum
enum : unsigned char
{
ENVNAME,
ENVVALUE,
Expand All @@ -220,7 +220,7 @@ class AllFields : public SimpleTable
QString text(int row, int col) override;

private:
enum
enum : unsigned char
{
FIELDNAME,
FIELDDESC,
Expand Down
12 changes: 6 additions & 6 deletions src/htable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool TableBody::isCellChanged(int row, int col)
else
{
bool result = false;
if (attr->text == str and attr->selected == selected and
if (attr->text == str.data() and attr->selected == selected and
attr->sorted == sorted and attr->xpos == xpos and attr->w == width
// and attr->size==tmp_size
and
Expand Down Expand Up @@ -336,10 +336,10 @@ bool TableHead::isCellChanged(int row, int col)
{
result = true;
}
else if (attr->text != str || attr->sorted != sorted
else if (attr->text != str.data() || attr->sorted != sorted
|| attr->size != tmp_size || attr->xpos != xpos)
{
attr->text = str;
attr->text = str.data();
attr->sorted = sorted;
attr->xpos = xpos;
attr->size = tmp_size;
Expand Down Expand Up @@ -482,7 +482,7 @@ void TableBody::paintCell(QPainter *p, int row, int col)
p->drawText(gap, 0, w, h, align, htable->text(row, col));

// cache write!
attr->text = htable->text(row, col);
attr->text = htable->text(row, col).data();
attr->xpos = htable->colXPos(col);
attr->size = tmp_size;
}
Expand Down Expand Up @@ -923,7 +923,7 @@ void TableCache::setRow(int row)
for (i = row; i < nrow; i++)
{
for (int j = 0; j < 48; j++)
rows[i]->cells[j].text = "";
rows[i]->cells[j].text = reinterpret_cast<const QChar *>("");
}
}
nrow = row;
Expand All @@ -939,7 +939,7 @@ void TableCache::setCol(int col)
int i, size = rows.size();
for (i = 0; i < size; i++)
for (int j = col; j < ncol; j++)
rows[i]->cells[j].text = "";
rows[i]->cells[j].text = reinterpret_cast<const QChar *>("");
}
ncol = col;
}
Expand Down
24 changes: 12 additions & 12 deletions src/htable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ class HeadedTable;
class CellAttribute
{
public:
QString text;
bool selected;
bool sorted;
const QChar *text;
QSize size;
QColor backColor; // table share
QColor foreColor; // rows share
int xpos; // cols share
int ypos; // rows share
int w; // cols share
int depth; // rows share
int folded; //
int lastchild; //
unsigned short xpos; // cols share
unsigned short ypos; // rows share
unsigned short w; // cols share
unsigned short depth; // rows share
unsigned short folded; //
unsigned short lastchild; //
bool selected;
bool sorted;
CellAttribute()
{
text = "";
text = nullptr;
sorted = selected = false;
xpos = -1, ypos = -1, w = 0, depth = -1, folded = -1;
lastchild = 0;
Expand Down Expand Up @@ -212,7 +212,7 @@ class TableBody : public QtTableView
int first_drag_row; // row where drag started
int prev_drag_row; // row where drag was at last event
bool autoscrolling; // true if we are autoscrolling right now
enum
enum : unsigned char
{
UP,
DOWN
Expand All @@ -237,7 +237,7 @@ class HeadedTable : public QWidget
TableBody *body;

CellAttribute *attr; // DEL temporarily buffer
enum NodeState
enum NodeState : unsigned char
{
Leaf,
Open,
Expand Down
14 changes: 7 additions & 7 deletions src/infobar.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,22 @@ class GraphBase : public QWidget
virtual QString doHistoryTXT(SysHistory *sysh);

Procview *procview;
int official_height;
int npoints; // nr of history points currently remembered
unsigned short official_height;
unsigned short npoints; // nr of history points currently remembered
private:
// history points are stored in fixed point, scaled by history_scale
static const unsigned int history_scale = 256;

int hist_size; // history buffer size DEL
float *history; // (circular) history buffer DEL
int h_index; // next history index to use
float peak; // largest value in history
float *history; // (circular) history buffer DEL
unsigned short hist_size; // history buffer size DEL
unsigned short h_index; // next history index to use

unsigned short px, py; // pointer position

bool dirty; // history changed since pixmap was drawn
QPixmap pixmap;
QPixmap icon_pm;

int px, py; // pointer position
};

class IO_Graph : public GraphBase
Expand Down
15 changes: 15 additions & 0 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,32 @@ extern bool flag_thread_ok;
#include <cstdarg>
#include <cstring>

#ifdef __AVX2__
#include <immintrin.h>
#endif

// 300% faster than glibc (by [email protected])
int x_atoi(const char *sstr)
{
const char *str = sstr;
int val = 0;
#ifdef __AVX2__
__m256i val_vec = _mm256_setzero_si256();
__m256i ten_vec = _mm256_set1_epi32(10);
while (*str && (str[0] >= '0' && str[0] <= '9')) {
val_vec = _mm256_mullo_epi32(val_vec, ten_vec);
val_vec = _mm256_add_epi32(val_vec, _mm256_set1_epi32(*str - '0'));
str++;
}
val = _mm256_extract_epi32(val_vec, 0); // Extract the first integer
#else
while (*str)
{
val *= 10;
val += *str - 48;
str++;
}
#endif
return val;
}

Expand Down
8 changes: 5 additions & 3 deletions src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
#include <QTimeLine>
#include <QTabWidget>

char *userName(int uid, int euid);
char *groupName(int gid, int egid);
int x_atoi(const char *sstr);

const QString userName(int uid, int euid);
const QString groupName(int gid, int egid);

void setQpsTheme();

Expand Down Expand Up @@ -116,7 +118,7 @@ class TBloon : public QLabel
// virtual void moveEvent (QMoveEvent * event );
private:
QWidget *paren;
QString text;
const QChar *text;
QTimeLine *timeLine;
};

Expand Down
Loading