Skip to content

Tweak QSPI FIFO_THRESH - #2679

Merged
labbott merged 2 commits into
masterfrom
qspi_fifo_tweak
Sep 14, 2026
Merged

labbott merged 2 commits into
masterfrom
qspi_fifo_tweak

Conversation

@labbott

@labbott labbott commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

The QPSI hardware has an internal FIFO with a configurable threshold to generate an interrupt. We currently have it set to 16 (50%). This results in many context switches because we wait for an interrupt when it drops below that threshold. Turning it down improves performance at the cost of blocking for longer periods of time.

Baseline
laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000 humility: WARNING: archive on command-line overriding archive in environment file humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3 HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real 0m7.480s
user 0m3.315s
sys 0m0.562s

FIFO_THRESH 8

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000 humility: WARNING: archive on command-line overriding archive in environment file humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3 HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real 0m6.504s
user 0m3.235s
sys 0m0.498s

FIFO_THRESH 4

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000 humility: WARNING: archive on command-line overriding archive in environment file humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3 HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real 0m6.480s
user 0m3.242s
sys 0m0.495s

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000 humility: WARNING: archive on command-line overriding archive in environment file humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3 HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real 0m6.196s
user 0m3.210s
sys 0m0.485s

@labbott
labbott requested review from hawkw and jamesmunns September 10, 2026 18:23
@hawkw

hawkw commented Sep 10, 2026

Copy link
Copy Markdown
Member

Sorry, just to clarify, are the second two runs in the PR description both with FIFO_THRESH=4, or is the last one with a different value?

Edit: ah, after looking at the PR, i think i know the value lol:
465b42f#diff-bc95876f185689c4350fde6ec29ed919d83c8c48cbc92e1f67d1eb62081af0feR20


const FIFO_SIZE: usize = 32;
const FIFO_THRESH: usize = 16;
const FIFO_THRESH: usize = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment describing why we set this to 1 might be nice here, but i suppose it's in the commit history.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a brief comment

The QPSI hardware has an internal FIFO with a configurable
threshold to generate an interrupt. We currently have
it set to 16 (50%). This results in many context switches
because we wait for an interrupt when it drops below
that threshold. Turning it down improves performance
at the cost of blocking for longer periods of time.

Baseline
laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3
HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real    0m7.480s
user    0m3.315s
sys     0m0.562s

FIFO_THRESH 8

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3
HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real    0m6.504s
user    0m3.235s
sys     0m0.498s

FIFO_THRESH 4

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3
HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real    0m6.480s
user    0m3.242s
sys     0m0.495s

laura@cadbury ~ $ time pfexec humility -t c71 -a ~/build-gimlet-c-lab-image-default.zip hiffy -c HostFlash.hash -aaddress=0,len=33554432 --timeout 1000000
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0483:3754:001100184741500820383733 via ST-Link V3
HostFlash.hash() => [ 0x9c, 0x41, 0xaf, 0x46, 0x10, 0xb8, 0x55, 0x1f, 0x28, 0x5a, 0xf6, 0xbe, 0xd7, 0x84, 0x2c, 0xab, 0xc6, 0xa4, 0x2a, 0xf4, 0x90, 0x93, 0x88, 0x8a, 0xc9, 0x61, 0x39, 0xf3, 0xde, 0xee, 0x86, 0x1d ]

real    0m6.196s
user    0m3.210s
sys     0m0.485s
@labbott
labbott enabled auto-merge (rebase) September 14, 2026 16:23
@labbott
labbott merged commit 8b6cbe4 into master Sep 14, 2026
196 checks passed
@labbott
labbott deleted the qspi_fifo_tweak branch September 14, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants