Skip to content

Comments

Pure kmp (remove wrappers)#8

Closed
Wavesonics wants to merge 10 commits intoJojo4GH:masterfrom
Wavesonics:pure-kmp
Closed

Pure kmp (remove wrappers)#8
Wavesonics wants to merge 10 commits intoJojo4GH:masterfrom
Wavesonics:pure-kmp

Conversation

@Wavesonics
Copy link
Contributor

@Wavesonics Wavesonics commented Dec 29, 2025

Okay I realize this is a lot of PRs, but you can choose your own adventure here, they all stack on each other:

  1. Just add the iOS targets, I verified with some tests that they are good to go
  2. Take the iOS targets plus the tests ported over from Kuba, this also adds a CI task for github to run the tests
  3. Pure Kotlin Zip: This branch is mainly a demonstration, proving out that a pure Kotlin implementation is possible, and only about 15% slower than native
  4. The whole hog: (this one) Removes all of the wrapper implementations, goes pure KMP, adds iOS, adds tests and CI

Updated to the latest headers fronm kuba
- Converted the C test suite from Kuba Zip to Kotlin
- Switched the JVM implementation to zip4j because the built in JVM implementation packed Append functionality. This allowed the JVM impl to pass the whole test suite
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 Wavesonics changed the title Pure kmp (remove wrapers) Pure kmp (remove wrappers) Dec 29, 2025
@Wavesonics Wavesonics changed the title Pure kmp (remove wrappers) Pure kmp (_remove wrappers_) Dec 29, 2025
@Wavesonics Wavesonics changed the title Pure kmp (_remove wrappers_) Pure kmp (remove wrappers) Dec 29, 2025
@Jojo4GH
Copy link
Owner

Jojo4GH commented Dec 29, 2025

You are doing some amazing work. Thank you very much!
I will use this PR as the place for discussing the changes.

iOS targets: The PR looks good and the idea of including the zip.c makes sense. Could you share your build process for the binaries? Currently there is no practical way for others to verify the binaries we provide, so I would like reproduce the build in the CI. Ideally we can remove all binaries and instead let gradle build them from source (#4).

Test: Porting the tests from Kuba is also a great idea. Maybe this could be converted into a PR that is independent from the addition of iOS targets? Also the move to zip4j looks good. iirc a while back I looked at zip4j for similar reasons, which is why the dependency was still there.

Pure Kotlin: Obviously the ideal solution regarding feature parity and portability. The main reason I did not do this in the past is because I do not feel comfortable maintaining the actual implementation for zip. But maybe this is something we can use for the web targets for now.

@Wavesonics
Copy link
Contributor Author

closing this in favor of the more targets PRs

@Wavesonics Wavesonics closed this Dec 29, 2025
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