Commit Graph

27 Commits

Author SHA1 Message Date
Miran 2de3844c6e
update ci.yml and be more explicit in .nimble (#30)
* update ci.yml and be more explicit in .nimble

* import results: get rid of the deprecated warning
2024-06-26 02:20:44 +00:00
Zahary Karadjov ef7be6daaf
Add codec.isSnappyFramedStream 2023-09-12 01:49:42 +03:00
Jacek Sieka 754715dfe7
fix indexdefect on invalid framed data (#24)
* fix fuzzer so that it doesn't do exact comparison - this doesn't work
any more because the implementations no longer match byte-for-byte -
instead, we check that the libraries agree on valid/invalid and that C++
can decompress snappy-encoded data
2023-09-10 01:40:05 +03:00
Jacek Sieka ecbcee1d10
allow skipping crc32 integrity check (#22)
Some data is already protected by stronger checks - crc32 on the other
hand significantly slows down framed reading - ie 2.5x slower:

```
118.853 / 41.781, 129.115 /  0.000, 188.438 /  0.000,  90.565 / 44.371,           50,    115613038, state-6800000-488b7150-d613b584.ssz
186.600 / 97.202, 191.935 /123.325,   0.000 /  0.000,   0.000 /  0.000,           50,    115613038, state-6800000-488b7150-d613b584.ssz(framed)
```

The difference between unframed and framed decoding is the CRC32 check -
it takes ~50ms on a decent laptop for a 110mb file.
2023-07-25 18:50:36 +03:00
Jacek Sieka e36f19d886
clean up Defect (#21) 2023-07-21 14:44:16 +02:00
Jacek Sieka 235c33c5ef
normalise nimble, update ci, fix warnings (#14)
* normalise nimble, update ci, fix warnings

* bump snappycpp

* lower macos builder version

newer clang is more restrictive than snappycpp supports
2022-11-24 12:22:15 +01:00
Jacek Sieka 7cb2e57a58
snappy revamp (#10)
This is a more or less complete revamp of the snappy library aiming to:

* clear out a lot of the duplicate code
* remove some of the redundant API
* unify the codebase behind a single, optimized "inner" encoder/decoder
* unify the public API for in-memory and stream
compression/decompression
* improve performance

As such, only the documented API remains backwards-compatible - the rest
has been refactored, moved around and rewritten:

* `import snappy` now exposes only in-memory encoders / decoders
* framed format moved to `snappy` module, `snappy/framing` removed
* faststreams integration moved to `snappy/faststreams`
* minimal `std/streams` integration started in `snappy/streams`

Other changes include:

* up-to-date documentation
* allocation- and exception-free API (uses some amount of stack memory)
* a 2-3x improvement to both compression and decompression performance,
putting the library mostly on par with the C++ implementation (see
README)
* the implementation was heavily inspired by the `C++`, `C` and `go`
implementations, but somewhat simplified
* nonetheless, the code uses a significant amount of unsafe code to
work around inefficiencies in the safe subset of Nim

With bulk operations in place, the cost of range checks falls
significantly - we can reintroduce them without any significant loss in
performance by carefully ordering operations such that optimizers can
elide most.
2022-04-14 16:22:41 +02:00
Jacek Sieka 16bf7b7d96
deduplicate and reorganise code (#9)
The snappy codebase is a mess with competing implementations,
nonsensical code duplication and no real direction due to a partially
implemented faststreams migration.

This PR makes it slightly less of a mess, but make no mistake, it's
still a mess - the difference being that there are a few more signposts
along the way in terms of module organisation, and a little less mess as
the line count of the PR discloses.

Performance remains poor - ~3x slower than C++ - but at least there's
less code to look at :)
2022-04-01 12:57:39 +02:00
Jacek Sieka 6afa8377e1
raises annotations for framed format 2022-03-28 14:08:06 +02:00
Etan Kissling d555230013 avoid unnecessary compression of short payloads
When using `framingFormatCompress`, the given payload is compressed to
determine whether its compressed form is shorter than its raw form.
For short payloads the Snappy compression will never be shorter, so it
is not necessary to compress such payloads. Instead, short payloads can
always be treated as uncompressable data. This patch optimizes for that.
2021-12-14 23:18:34 +07:00
jangko 22dbb2eb65
fixes fishy and dubious codes 2021-02-03 19:17:19 +07:00
Jacek Sieka 07cea69de5
fix unnecessary seq allocation
this significantly slows down the implementation
2020-08-26 15:52:15 +02:00
Zahary Karadjov a368549c1a
Fix various integer overflow issues found through fuzzing 2020-08-18 23:11:42 +03:00
jangko 700f7777fd
fix crc32c nim side crash 2020-05-23 13:21:55 +07:00
Zahary Karadjov f6a87764a3
Added fuzzing tests 2020-05-20 21:06:13 +03:00
Zahary Karadjov b4cd68e27a
Add a helper for framing compression of blobs 2020-05-12 22:30:21 +03:00
Zahary Karadjov 20cc8ce1c2
Export more constants, so they can be used in NBC 2020-05-08 22:24:16 +03:00
Zahary Karadjov 5e9e2a1f65
Async version of the Snappy framing format based on the latest FastStreams version 2020-05-06 00:35:55 +03:00
Zahary Karadjov b1726ab7e7
Add a helper for one-shot framing-format decompression 2020-04-16 14:59:42 +03:00
Zahary Karadjov 80cff583e3
More faststrams upgrades; Re-enable the file-based tests 2020-04-14 17:00:40 +03:00
Zahary Karadjov b5196c17b6
Use the latest faststreams OutputStream API 2020-04-13 15:02:41 +03:00
andri lim f08cbf9dc5 working snappy framing compress prototype 2020-04-01 22:35:57 +03:00
andri lim 45b8258af4 renormalize *.txt EOL 2020-04-01 22:35:57 +03:00
andri lim 73bb7db070 working framing uncompress prototype 2020-04-01 22:35:57 +03:00
andri lim bb20886854 implement crc stuff 2020-04-01 22:35:57 +03:00
andri lim 4dc604a5ca add framing format spec file 2020-04-01 22:35:57 +03:00
andri lim aafdb7c8e6 move maxEncodedLen to snappy/utils.nim 2020-04-01 22:35:57 +03:00