Skip to content

perf: eliminate redundant JSON marshal/unmarshal in convertJSONToParquet - #26

Merged
ngoyal16 merged 1 commit into
mainfrom
feat/optimize-convert-json-parquet-memory
Sep 29, 2026
Merged

ngoyal16 merged 1 commit into
mainfrom
feat/optimize-convert-json-parquet-memory

Conversation

@ngoyal16

Copy link
Copy Markdown
Contributor

Fixes #16

Summary of Changes

  • Direct Struct Mapping: Replaced the per-event json.Marshal + json.Unmarshal loop in convertJSONToParquet with a fast, zero-serde helper function mapToDatabaseActivityEvent.
  • Allocation & GC Reduction: Eliminated double JSON reflection, dynamic heap allocations, and text re-parsing per record.
  • Buffer Pre-Allocation: Added buf.Grow(len(decompressedJSON) / 2) to minimize buffer resizing during Parquet compression.
  • Microbenchmarks Added:
    • BenchmarkMapToDatabaseActivityEvent: Executes in ~180 ns/op with 1 allocation (32 B/op).
    • BenchmarkConvertJSONToParquet: Continuous performance tracking for Parquet generation on DAS event fixtures.
  • Unit Test Coverage: Added comprehensive tests in convert_test.go verifying all 21 struct fields, string/int64 conversions, and slice handling.
  • Test Coverage: Increased repository statement coverage to 84.7%.

…uet (#16)

- Add mapToDatabaseActivityEvent and type-safe helpers (getString, getInt64, getStringSlice) to directly convert generic maps to DatabaseActivityEvent
- Eliminate per-event json.Marshal and json.Unmarshal loop in convertJSONToParquet
- Pre-allocate output buffer capacity (buf.Grow) to minimize heap allocations
- Add unit tests verifying all 21 struct field conversions and type coercions
- Add BenchmarkConvertJSONToParquet and BenchmarkMapToDatabaseActivityEvent (showing 180ns/op and 1 alloc/op)
- Increase test statement coverage to 84.7%
@ngoyal16
ngoyal16 merged commit 7e5a45d into main Sep 29, 2026
9 checks passed
@ngoyal16
ngoyal16 deleted the feat/optimize-convert-json-parquet-memory branch September 29, 2026 17:28
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.

Optimize memory usage and eliminate redundant JSON marshal/unmarshal in convertJSONToParquet

1 participant