Giter Site home page Giter Site logo

Use a serialization library about pgx HOT 4 OPEN

arenadotio avatar arenadotio commented on June 27, 2024 1
Use a serialization library

from pgx.

Comments (4)

brendanlong avatar brendanlong commented on June 27, 2024

I did some experimentation with Angstrom and my basic parser was an order of magnitude slower than Pgx's current code. I might try a little bit more experimentation with flambda. It's also awkward to write since OCaml doesn't have unsigned types, so we either need to use the integers library, which uses C code and is significantly slower, or pass around uint32's as int64's 🤮

from pgx.

brendanlong avatar brendanlong commented on June 27, 2024

We should probably look into how PG'OCaml and Postgres_async do serialization and see if we can come up with a base parser/serializer library that they could both theoretically use too.

from pgx.

brendanlong avatar brendanlong commented on June 27, 2024

Nevermind, it looks like if we add Async overhead into account, Angstrom_async actually reads data more efficiently than Pgx does, which massively swamps the difference in parse speed:

Estimated testing time 14s (14 benchmarks x 1s). Change using '-quota'.
┌─────────────────────────────────────────────────────────┬────────────┬─────────┬──────────┬──────────┬────────────┐
│ Name                                                    │   Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├─────────────────────────────────────────────────────────┼────────────┼─────────┼──────────┼──────────┼────────────┤
│ Authentication_ok.parse (string)                        │   441.74ns │ 281.26w │          │          │     10.68% │
│ Authentication_ok.parse (bigstring)                     │   403.78ns │ 272.24w │          │          │      9.77% │
│ Authentication_ok_int.parse (string)                    │   190.38ns │ 221.11w │          │          │      4.60% │
│ Authentication_ok_int.parse (bigstring)                 │   123.72ns │ 212.07w │          │          │      2.99% │
│ Authentication_ok_int_lift.parse (string)               │   158.35ns │ 155.09w │          │          │      3.83% │
│ Authentication_ok_int_lift.parse (bigstring)            │    93.14ns │ 146.00w │          │          │      2.25% │
│ Authentication_ok_int_lift.parse (unbuffered bigstring) │    96.23ns │ 169.00w │          │          │      2.33% │
│ Authentication_ok_int_lift.parse (async)                │ 3_497.32ns │ 678.75w │    0.35w │    0.35w │     84.59% │
│ Authentication_ok_int64.parse (string)                  │   205.84ns │ 251.00w │          │          │      4.98% │
│ Authentication_ok_int64.parse (bigstring)               │   146.00ns │ 242.00w │          │          │      3.53% │
│ Authentication_ok_int_simple.parse (string)             │   183.80ns │ 211.00w │          │          │      4.45% │
│ Authentication_ok_int_simple.parse (bigstring)          │   122.37ns │ 202.00w │          │          │      2.96% │
│ Pgx                                                     │    23.40ns │  22.00w │          │          │      0.57% │
│ Pgx_async                                               │ 4_134.51ns │ 639.19w │    0.29w │    0.29w │    100.00% │
└─────────────────────────────────────────────────────────┴────────────┴─────────┴──────────┴──────────┴────────────┘

I'll clean this up and put up a basic repo sometime soon.

from pgx.

brendanlong avatar brendanlong commented on June 27, 2024

I started working on this here: https://github.com/brendanlong/ocaml-postgres-protocol

from pgx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.