Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Publishing symbol graph bson #338

wti started this conversation in General
Discussion options

The symbolgraph binary bson files captured during swiftinit builds could be quite useful for third-party analysis.

With the unidoc tool, folks can compile them independently, but making the binaries publicly available would relieve said third parties from that hard work.

If/since the binaries are stored per-package and referenced on each package page, each could be linked from there for manual download.

My own goal is scaling analysis for many packages, so it would be nice to have an officially permitted way to get e.g., 100 or 1000+ packages at a time. I believe the consumer would be responsible for aligning both package and bson versions and comply with size/frequency throttling to avoid egress costs. Because batching could be a bit of work with a different cost/benefit profile, it can be split off as another issue. My own foreseeable need is only for one big batch.

Batch and package users might both need some way to avoid comparing across versions. Each file includes the symbol graph ABI version as a bson field, and the metadata for each package dependency seems to include a version. For the package itself, direct users are typically clicking on a versioned link, but batch users might need a version for the package represented in the bson file (perhaps encoded in the file name?).

For context, please see
https://forums.swift.org/t/documentation-workgroup-meeting-september-9th-2024/74420/7

You must be logged in to vote

Replies: 2 comments

Comment options

we recently pushed an update to the site that adds a Download link under the "..." menu next to each symbol graph entry on the tags pages.

please note that these files are zlib-compressed, so you will need to unarchive them using something like this:

case .bson_zz:
// https://github.com/apple/swift/issues/71605
var inflator:LZ77.Inflator = .init(format: .zlib)
try inflator.push((/* consume */ bytes)[...])
bytes = inflator.pull()
You must be logged in to vote
0 replies
Comment options

Thanks! I can download the bson (menu ... visible only after login) and load the SymbolGraph...

let source = try Data(contentsOf: graphUrl) 
try source.withUnsafeBytes { sourcePtr in
 var inflator: LZ77.Inflator = .init(format: .zlib)
 sourcePtr.withMemoryRebound(to: UInt8.self) { sourceBytes in
 let slice: ArraySlice<UInt8> = .init(sourceBytes)
 try inflator.push(slice)
 }
 let bytes = inflator.pull()
 let bson: BSON.Document = .init(bytes: bytes[...])
 return try UDSymbolGraph(bson: bson)
}

Using packages swift-mongodb (bson), swift-unidoc (SymbolGraph), and swift-png (LZ77)

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #333 on September 13, 2024 21:03.

AltStyle によって変換されたページ (->オリジナル) /