{"action":"created","issue":{"url":"https://api.github.com/repos/JasperFx/marten/issues/642","repository_url":"https://api.github.com/repos/JasperFx/marten","labels_url":"https://api.github.com/repos/JasperFx/marten/issues/642/labels{/name}","comments_url":"https://api.github.com/repos/JasperFx/marten/issues/642/comments","events_url":"https://api.github.com/repos/JasperFx/marten/issues/642/events","html_url":"https://github.com/JasperFx/marten/pull/642","id":196218012,"number":642,"title":"[WIP] Buffer pooling for JSON serialization","user":{"login":"Scooletz","id":519707,"avatar_url":"https://avatars.githubusercontent.com/u/519707?v=3","gravatar_id":"","url":"https://api.github.com/users/Scooletz","html_url":"https://github.com/Scooletz","followers_url":"https://api.github.com/users/Scooletz/followers","following_url":"https://api.github.com/users/Scooletz/following{/other_user}","gists_url":"https://api.github.com/users/Scooletz/gists{/gist_id}","starred_url":"https://api.github.com/users/Scooletz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scooletz/subscriptions","organizations_url":"https://api.github.com/users/Scooletz/orgs","repos_url":"https://api.github.com/users/Scooletz/repos","events_url":"https://api.github.com/users/Scooletz/events{/privacy}","received_events_url":"https://api.github.com/users/Scooletz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-17T11:46:25Z","updated_at":"2016-12-30T10:22:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JasperFx/marten/pulls/642","html_url":"https://github.com/JasperFx/marten/pull/642","diff_url":"https://github.com/JasperFx/marten/pull/642.diff","patch_url":"https://github.com/JasperFx/marten/pull/642.patch"},"body":"**Work in progress**\r\n\r\nAddresses #640 \r\n\r\nThis PR Introduces `CharArrayTextWriter` that by provides access to its `char[]`. Additionally changes the way that driver parameters are created, enables reusing memory and reducing allocations for serializing.\r\n\r\nPlan\r\n- [x] change `DocJsonBodyArgument` to use pooled writer\r\n- [x] ~change `EventStreamAppender` to use pooled writers~\r\n- [x] test buffering\r\n- [ ] decide what's the best buffering strategy: \r\n  - one pool per app (current approach) \r\n  - one per `DocumentStore`\r\n  - additional pool for session to keep leased writers for reuse during the same session and return at the end of the session\r\n  - another one?\r\n- [ ] decide should this be `opt-in` or `opt-out` behavior\r\n\r\n**Notes:**\r\n- The `EventStreamAppender` can't be changed now as Npgsql does not support writing `ArraySegment<char>` as `jsonb`, `json` nor `string`. I took a look at the implementation of the driver at it would require a lot of work as the [WriteBuffer](https://github.com/npgsql/npgsql/blob/dev/src/Npgsql/WriteBuffer.cs#L331-L33378) does not have overloads for this. If we had it, then appending events would be easy."},"comment":{"url":"https://api.github.com/repos/JasperFx/marten/issues/comments/269755312","html_url":"https://github.com/JasperFx/marten/pull/642#issuecomment-269755312","issue_url":"https://api.github.com/repos/JasperFx/marten/issues/642","id":269755312,"user":{"login":"Scooletz","id":519707,"avatar_url":"https://avatars.githubusercontent.com/u/519707?v=3","gravatar_id":"","url":"https://api.github.com/users/Scooletz","html_url":"https://github.com/Scooletz","followers_url":"https://api.github.com/users/Scooletz/followers","following_url":"https://api.github.com/users/Scooletz/following{/other_user}","gists_url":"https://api.github.com/users/Scooletz/gists{/gist_id}","starred_url":"https://api.github.com/users/Scooletz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scooletz/subscriptions","organizations_url":"https://api.github.com/users/Scooletz/orgs","repos_url":"https://api.github.com/users/Scooletz/repos","events_url":"https://api.github.com/users/Scooletz/events{/privacy}","received_events_url":"https://api.github.com/users/Scooletz/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T10:22:44Z","updated_at":"2016-12-30T10:22:44Z","body":"I followed the way Marten handles dirty checking. This lead me to fetching documents which again uses strings. If we wanted to make no allocations that would require to change the fetch mechanism as well and use the char buffers in there.\r\n\r\n☝️ This is a some kind of note to myself. I'll try to play a little bit with it and post my findings in here."}}
{"actor":{"display_login":"Scooletz"}}