Project

General

Profile

Actions

Optimization #5718

closed

time: compact alternative to struct timeval

Added by Victor Julien almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Effort:
Difficulty:
Label:

Description

struct timeval uses 16 bytes of space on 64 bit Linux. This is far more than needed. This structure is embedded in various memory and cache sensitive data structures:
- flow 2x (lastts, startts)
- packet (ts)
- defrag tracker (timeout)
- stream (pcap hdr storage)

timeval has 2 fields we care about: tv_sec (seconds since epoch), tv_usec (micro seconds, range 0-1000000).

If we'd use a simple uint64_t of usecs since epoch, we'd be able to express 1970-infinity.
We could further shrink it to 52 bits, which would express 1970-2100 - these 12 bits we'd further save could hold a vlan id?

E.g.:

uint64_t startts_usecs:52;
uint64_t vlan_id1:12;

When setting/checking the timestamp we'd need some helpers to set it from a struct timeval, be able to compare it with one, etc.

Actions #1

Updated by Jeff Lucovsky almost 2 years ago

  • Status changed from New to In Review
  • Assignee changed from OISF Dev to Jeff Lucovsky
Actions #2

Updated by Jeff Lucovsky almost 2 years ago

  • Status changed from In Review to Closed
Actions #3

Updated by Jeff Lucovsky over 1 year ago

  • Target version changed from TBD to 7.0.0
Actions #4

Updated by Jeff Lucovsky over 1 year ago

  • Target version changed from 7.0.0 to 7.0.0-rc2
Actions

Also available in: Atom PDF