René's URL Explorer Experiment


Title: Simplify and tighten the @perf_event API by congwang-mk · Pull Request #23 · multikernel/kernelscript · GitHub

Open Graph Title: Simplify and tighten the @perf_event API by congwang-mk · Pull Request #23 · multikernel/kernelscript

X Title: Simplify and tighten the @perf_event API by congwang-mk · Pull Request #23 · multikernel/kernelscript

Description: Summary Reworks the @perf_event user-facing API for safety, consistency, and a smaller compiler footprint. Five focused commits: Fold perf_type + perf_config into one event constant. The two old fields had to agree (every config belongs to exactly one type — cache_misses is always hardware), and mismatching them was a silent footgun. A single perf_event enum now packs the perf_event_attr.type tag in the high 32 bits and the config in the low 32 bits, so naming the event fixes both. // before attach(prog, perf_options { perf_type: perf_type_hardware, perf_config: cache_misses }, 0) // after attach(prog, perf_options { event: cache_misses }, 0) Single-source the encoding in stdlib. The PMU-slot analysis had hard-coded the bit layout (>> 32, type tags) and the enum name in the type checker, duplicating what stdlib defined. The layout now lives only in stdlib (perf_event_pack); the type checker resolves the constant generically. Remove the host-dependent static perf-group PMU-budget check. It rejected groups needing more PMU counters than a limit read from the build host's sysfs (or a guessed default of 4) — the wrong layer for a host-dependent resource check, and wrong under cross-compilation. The kernel already enforces group sizing authoritatively at perf_event_open(2) on the real host, and the generated runtime reports it. This removes ~240 lines and all perf-group/PMU/encoding knowledge from type_checker.ml (perf references: 55 → 11, the survivors being the same uniform per-program-type handling @xdp/@kprobe get). Drop the raw group_fd field from perf_options. It exposed a kernel ABI integer alongside the typed group handle. Since every perf fd comes from attach() as a perf_attachment, the raw form was redundant; grouping is now expressed only via group. group_fd: now fails type checking as an unknown field. snake_case the perf types. PerfAttachment → perf_attachment, PerfRead → perf_read, so the whole perf surface matches perf_options and the rest of the language. Behavioral notes Capability trimmed (deliberately): the unified event enum currently covers the named hardware/software events (everything examples/tests used). The old tracepoint/hw_cache/raw/breakpoint type tags and arbitrary numeric configs are not expressible; they can return as encoded enum entries or a raw_event(type, config) constructor if needed. No safety regression from removing the static check: oversized hardware groups fail at perf_event_open(2); >16-member software groups truncate-with-warning in the bounded group read (no overflow); group cycles are already prevented by use-before-definition; non-leader group references are rejected by the kernel. Verification Full test suite green (dune runtest, exit 0). Both perf examples (perf_cache_miss, perf_page_fault) compile and the generated C builds to working binaries — including the software-event path that crosses the 32-bit encoding boundary. Docs (README, SPEC, BUILTINS) updated throughout. Net: +180 / −633 lines. 🤖 Generated with Claude Code

Open Graph Description: Summary Reworks the @perf_event user-facing API for safety, consistency, and a smaller compiler footprint. Five focused commits: Fold perf_type + perf_config into one event constant. The two old ...

X Description: Summary Reworks the @perf_event user-facing API for safety, consistency, and a smaller compiler footprint. Five focused commits: Fold perf_type + perf_config into one event constant. The two old ...

Opengraph URL: https://github.com/multikernel/kernelscript/pull/23

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:97bfeda0-9065-a942-56fd-59a0f8b04125
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9892:11D53A:26A2DA:347F56:6A6290D7
html-safe-nonce9c0f996b3274d7210b406573315642d676251133fec059848aa1b519fa160b0a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODkyOjExRDUzQToyNkEyREE6MzQ3RjU2OjZBNjI5MEQ3IiwidmlzaXRvcl9pZCI6IjgwMTY4MTQ2Mzg4NDI5NDE2NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac490b142c32e6cf61e50cd7d2ec8ea6c862778deae5bac1f3ac2facec9dd2d477
hovercard-subject-tagpull_request:3944137611
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/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/multikernel/kernelscript/pull/23/files
twitter:imagehttps://avatars.githubusercontent.com/u/227915880?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/227915880?s=400&v=4
og:image:altSummary Reworks the @perf_event user-facing API for safety, consistency, and a smaller compiler footprint. Five focused commits: Fold perf_type + perf_config into one event constant. The two old ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneac2209d8cb6970a1bd08cb0a3f821d7166ac544c2ca1c87819c335bb84310ecd
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/multikernel/kernelscript git https://github.com/multikernel/kernelscript.git
octolytics-dimension-user_id202362072
octolytics-dimension-user_loginmultikernel
octolytics-dimension-repository_id1019261571
octolytics-dimension-repository_nwomultikernel/kernelscript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1019261571
octolytics-dimension-repository_network_root_nwomultikernel/kernelscript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2fca8cd598678aaa64706088ad13b4e19177e108
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/multikernel/kernelscript/pull/23/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmultikernel%2Fkernelscript%2Fpull%2F23%2Ffiles
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%2Fmultikernel%2Fkernelscript%2Fpull%2F23%2Ffiles
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%2Ffiles&source=header-repo&source_repo=multikernel%2Fkernelscript
Reloadhttps://github.com/multikernel/kernelscript/pull/23/files
Reloadhttps://github.com/multikernel/kernelscript/pull/23/files
Reloadhttps://github.com/multikernel/kernelscript/pull/23/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
multikernel https://github.com/multikernel
kernelscripthttps://github.com/multikernel/kernelscript
Notifications https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Fork 23 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Star 501 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Code https://github.com/multikernel/kernelscript
Issues 2 https://github.com/multikernel/kernelscript/issues
Pull requests 0 https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality 0 https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Code https://github.com/multikernel/kernelscript
Issues https://github.com/multikernel/kernelscript/issues
Pull requests https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
congwang-mkhttps://github.com/congwang-mk
mainhttps://github.com/multikernel/kernelscript/tree/main
perf-event-fold-typehttps://github.com/multikernel/kernelscript/tree/perf-event-fold-type
Conversation 0 https://github.com/multikernel/kernelscript/pull/23
Commits 5 https://github.com/multikernel/kernelscript/pull/23/commits
Checks 1 https://github.com/multikernel/kernelscript/pull/23/checks
Files changed https://github.com/multikernel/kernelscript/pull/23/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
Simplify and tighten the @perf_event API https://github.com/multikernel/kernelscript/pull/23/files#top
Show all changes 5 commits https://github.com/multikernel/kernelscript/pull/23/files
3696653 Fold perf_type into a single packed perf_event constant congwang-mk Jun 26, 2026 https://github.com/multikernel/kernelscript/pull/23/commits/3696653d01a34fc4c218b33b0fbbf8d253647235
3a0061f Make stdlib the single source of truth for perf_event encoding congwang-mk Jun 26, 2026 https://github.com/multikernel/kernelscript/pull/23/commits/3a0061f0065c4fd4ac83e7db700f4949d48555a7
5ff8d80 Remove host-dependent static perf-group PMU-budget check congwang-mk Jun 26, 2026 https://github.com/multikernel/kernelscript/pull/23/commits/5ff8d80edbd5af56ae500c24488c88a6a8627f77
7125c47 Drop raw group_fd field from perf_options congwang-mk Jun 26, 2026 https://github.com/multikernel/kernelscript/pull/23/commits/7125c4787e460069cc8e8243e7d5b6f04a49484a
1011bd6 Rename PerfAttachment/PerfRead to snake_case congwang-mk Jun 26, 2026 https://github.com/multikernel/kernelscript/pull/23/commits/1011bd657356d8f22e00c4be0ed17e87472d7028
Clear filters https://github.com/multikernel/kernelscript/pull/23/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
BUILTINS.md https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
README.md https://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
SPEC.md https://github.com/multikernel/kernelscript/pull/23/files#diff-7426c9e3a694ca6015df5f98637912975f2edea23270203ee89a8bdeed246ee0
perf_cache_miss.ks https://github.com/multikernel/kernelscript/pull/23/files#diff-3a077caa1a1b884d8a97deec19362aea96f35ff290a32d44040226b70b0f20da
perf_page_fault.ks https://github.com/multikernel/kernelscript/pull/23/files#diff-4363a53a84908383ce551f4f162a666ea0e8239573a7ce9aa1f2f3cfe113af99
btf_parser.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-5b94502256671ab875f7f2e6e2d9d1b21719fcb3109673e0e5b51607a5a0678c
stdlib.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-c2bcdbff958f6b2d9ac690d4e0b39f68e001c8de8205b4b23ade032fd9654f16
type_checker.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-19547f3bd84789512c822f230e0efa538e8dcef3e62b677be000400b908496fa
userspace_codegen.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
test_perf_event_attach.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-32b71512077f01935dd07ed3c8418df81d10dc0ed25bb688085a3d28ad9b0c7a
test_program_ref.ml https://github.com/multikernel/kernelscript/pull/23/files#diff-d9316833291c3479d9deb9547718856180a99db21865c6d8a2f6f4c72d142e8e
BUILTINS.mdhttps://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
View file https://github.com/multikernel/kernelscript/blob/1011bd657356d8f22e00c4be0ed17e87472d7028/BUILTINS.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/23/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
https://github.com/multikernel/kernelscript/pull/23/files#diff-a6fbfd5d0465bb0a334eaf5de654b53e43f83a1e0e18e7ba740fffb790e4bced
README.mdhttps://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
View file https://github.com/multikernel/kernelscript/blob/1011bd657356d8f22e00c4be0ed17e87472d7028/README.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/23/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
https://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
https://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
https://github.com/multikernel/kernelscript/pull/23/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/23/files
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.