René's URL Explorer Experiment


Title: Optimize reverb buffer locality by Ali-Z0 · Pull Request #90 · sezero/mikmod · GitHub

Open Graph Title: Optimize reverb buffer locality by Ali-Z0 · Pull Request #90 · sezero/mikmod

X Title: Optimize reverb buffer locality by Ali-Z0 · Pull Request #90 · sezero/mikmod

Description: Summary Hi MikMod maintainers, My collaborator @thomasstaheli and I recently studied a MikMod-based audio pipeline as part of our High-Performance Computing course at HEIG-VD in Yverdon, Switzerland. During this work, we profiled the reverb mixing code and identified MixReverb_Stereo as a noticeable hotspot in the audio path. This pull request proposes two small optimizations for the reverb mixer: improving the memory layout of the reverb buffers; reducing the arithmetic cost of circular buffer indexing. The goal is to improve performance in a frequently executed DSP path without changing the reverb algorithm or the intended audio output. Motivation The stereo reverb mixer repeatedly accesses 16 circular buffers: RVbufL1 to RVbufL8 for the left channel; RVbufR1 to RVbufR8 for the right channel. In the original implementation, these buffers are allocated separately. This can scatter them across the heap and reduce spatial locality. Since the reverb loop reads and writes these buffers very frequently, a more cache-friendly layout can help reduce memory stalls. The inner loop also performs repeated modulo operations for circular indexing. These modulo operations may compile to integer divisions, which are relatively expensive compared to simple increments and comparisons. Changes 1. Contiguous reverb buffer allocation The separate reverb buffer allocations are replaced with a single contiguous allocation. The existing RVbufL* and RVbufR* pointers are then assigned linearly inside this block. This keeps the rest of the code structure mostly unchanged, while improving spatial locality and reducing heap fragmentation. 2. Strength reduction for circular indexing The repeated modulo-based index updates in the inner reverb loop are replaced with conditional increments: if (++loc >= RVc) loc = 0; The modulo is only needed for initialization. During the loop, the index advances with cheaper operations: increment, comparison, and conditional reset. Performance notes This change was motivated by profiling in a downstream project using MikMod-based audio mixing. In that environment, MixReverb_Stereo was one of the relevant audio hotspots. Using Linux perf, we observed the following self CPU cost for the targeted function: baseline run 1: 5.38%; baseline run 2: 5.69%; optimized run: 4.33%. Using the average of the two baseline runs, this corresponds to a relative reduction of approximately 21.8% for MixReverb_Stereo in that workload. These numbers are workload- and platform-dependent, so they should be interpreted as an indication rather than a universal benchmark. The main goal of this PR is to make the reverb buffer access pattern more cache-friendly and reduce unnecessary arithmetic in a hot loop. Compatibility The reverb algorithm is not intentionally changed. The existing buffer pointer interface is preserved, and the optimization only changes how the buffers are allocated and how circular indices are advanced internally. Please let us know if you would prefer the patch to be split differently, rebased, or adjusted to better match the coding style of the project. Best regards, @Ali-Z0 and @thomasstaheli

Open Graph Description: Summary Hi MikMod maintainers, My collaborator @thomasstaheli and I recently studied a MikMod-based audio pipeline as part of our High-Performance Computing course at HEIG-VD in Yverdon, Switzerlan...

X Description: Summary Hi MikMod maintainers, My collaborator @thomasstaheli and I recently studied a MikMod-based audio pipeline as part of our High-Performance Computing course at HEIG-VD in Yverdon, Switzerlan...

Opengraph URL: https://github.com/sezero/mikmod/pull/90

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:3f7db2d2-c94f-efda-d749-4a1a694961cc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9638:3C53BD:4DDCE8B:67B798E:6A655CAC
html-safe-nonce9ea2635b1295b197ac84256dfc65bca268e301ec27530d56bd0510aa4dd592af
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjM4OjNDNTNCRDo0RERDRThCOjY3Qjc5OEU6NkE2NTVDQUMiLCJ2aXNpdG9yX2lkIjoiNTExODYwMDc1NTA5MzUyNzcyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac82e111fb79d08412e646ff10374ccd15bbdf1c9da9dd577a9e1a48532d26b3d1
hovercard-subject-tagpull_request:3822799301
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
twitter:imagehttps://avatars.githubusercontent.com/u/107996590?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/107996590?s=400&v=4
og:image:altSummary Hi MikMod maintainers, My collaborator @thomasstaheli and I recently studied a MikMod-based audio pipeline as part of our High-Performance Computing course at HEIG-VD in Yverdon, Switzerlan...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/sezero/mikmod git https://github.com/sezero/mikmod.git
octolytics-dimension-user_id4222725
octolytics-dimension-user_loginsezero
octolytics-dimension-repository_id114225902
octolytics-dimension-repository_nwosezero/mikmod
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id114225902
octolytics-dimension-repository_network_root_nwosezero/mikmod
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsezero%2Fmikmod%2Fpull%2F90%2Fcommits%2F23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsezero%2Fmikmod%2Fpull%2F90%2Fcommits%2F23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=sezero%2Fmikmod
Reloadhttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Reloadhttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Reloadhttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
sezero https://github.com/sezero
mikmodhttps://github.com/sezero/mikmod
Notifications https://github.com/login?return_to=%2Fsezero%2Fmikmod
Fork 25 https://github.com/login?return_to=%2Fsezero%2Fmikmod
Star 88 https://github.com/login?return_to=%2Fsezero%2Fmikmod
Code https://github.com/sezero/mikmod
Issues 8 https://github.com/sezero/mikmod/issues
Pull requests 2 https://github.com/sezero/mikmod/pulls
Actions https://github.com/sezero/mikmod/actions
Security and quality 0 https://github.com/sezero/mikmod/security
Insights https://github.com/sezero/mikmod/pulse
Code https://github.com/sezero/mikmod
Issues https://github.com/sezero/mikmod/issues
Pull requests https://github.com/sezero/mikmod/pulls
Actions https://github.com/sezero/mikmod/actions
Security and quality https://github.com/sezero/mikmod/security
Insights https://github.com/sezero/mikmod/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsezero%2Fmikmod%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsezero%2Fmikmod%2Fissues%2Fnew%2Fchoose
Ali-Z0https://github.com/Ali-Z0
sezero:masterhttps://github.com/sezero/mikmod/tree/master
Ali-Z0:optimize-reverb-buffer-localityhttps://github.com/Ali-Z0/mikmod/tree/optimize-reverb-buffer-locality
Conversation 10 https://github.com/sezero/mikmod/pull/90
Commits 1 https://github.com/sezero/mikmod/pull/90/commits
Checks 0 https://github.com/sezero/mikmod/pull/90/checks
Files changed https://github.com/sezero/mikmod/pull/90/files
Please reload this pagehttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Optimize reverb buffer locality https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#top
Show all changes 1 commit https://github.com/sezero/mikmod/pull/90/files
23ee402 Optimize reverb buffer locality Ali-Z0 Jun 8, 2026 https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Clear filters https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Please reload this pagehttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
Please reload this pagehttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
virtch.c https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
virtch2.c https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
Please reload this pagehttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60
https://github.com/Ali-Z0
https://github.com/sezero
Ali-Z0https://github.com/sezero/mikmod/commits?author=Ali-Z0
sezerohttps://github.com/sezero/mikmod/commits?author=sezero
libmikmod/playercode/virtch.chttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
View file https://github.com/sezero/mikmod/blob/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60/libmikmod/playercode/virtch.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sezero/mikmod/pull/90/commits/{{ revealButtonHref }}
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-839e982d67875aa417ff2689247b4886e6c0ade3d5c84573644e920053f429a0
libmikmod/playercode/virtch2.chttps://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
View file https://github.com/sezero/mikmod/blob/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60/libmikmod/playercode/virtch2.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sezero/mikmod/pull/90/commits/{{ revealButtonHref }}
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com/sezero/mikmod/pull/90/commits/23ee402a1f6544a1aa66307c13cfb7e67ba2bc60#diff-a5b8b0dfaf62eb03c308e03d6406ff83da85da7483f8433121e642ba4933d518
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.