Skip to content

Comments

Kmp native implementation of Zip#6

Open
Wavesonics wants to merge 3 commits intoJojo4GH:masterfrom
Wavesonics:kmp-native
Open

Kmp native implementation of Zip#6
Wavesonics wants to merge 3 commits intoJojo4GH:masterfrom
Wavesonics:kmp-native

Conversation

@Wavesonics
Copy link
Contributor

@Wavesonics Wavesonics commented Dec 28, 2025

So I thought I'd try, just for fun, and possibly to support WASM targets, converting the C implementation, to pure Kotlin.

Obviously it would be slower, but it would be maximally compatible and simple!

So I did it, and then implemented some performance tests to see just how much slower it would be.

Well it turns out, it's still pretty good. This is using the Kompress KMP lib for the Deflate implementation.

Here are the performance results:
jvm_vs_kotlin

It's about 15% slower, but it's pure KMP, could run on WASM even. So that's pretty neat.

Added performance tests to compare it against the C implementation
1.
Streaming Read/Write: The implementation no longer loads the entire ZIP file or its entries into memory. It now uses a DataSource system to defer data access until the final write operation.
2.
Random Access Seeking: I implemented platform-specific random-access seeking (openSourceAt) for JVM (using RandomAccessFile) and Native (using fseek). This eliminated the $O(N^2)$ overhead caused by Source.skip, which previously read and discarded data from the start of the file for every entry.
3.
Optimized CRC32: Replaced the naive bit-by-bit CRC32 with a high-performance table-based implementation.
@Wavesonics
Copy link
Contributor Author

separated this from the other PRs, no longer includes iOS or test stuff

@morki
Copy link

morki commented Jan 30, 2026

Any progress here? It would be awesome :)

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