Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid marshalling every packet to a string when not in debug mode #26

Closed
wants to merge 1 commit into from

Conversation

djs55
Copy link
Member

@djs55 djs55 commented Nov 19, 2015

The Log.debug function will create a string to be logged via

Fmt.kstrf (fun s -> if !print_debug then print_endline s) fmt

before deciding whether to print them or not. In debug mode we print every
packet received and transmitted. This patch ensures that, when not in
debug mode, we don't generate vast quantities of strings which we never
print.

Signed-off-by: David Scott dave.scott@unikernel.com

The `Log.debug` function will create a string to be logged via

```
Fmt.kstrf (fun s -> if !print_debug then print_endline s) fmt
```

before deciding whether to print them or not. In debug mode we print every
packet received and transmitted. This patch ensures that, when not in
debug mode, we don't generate vast quantities of strings which we never
print.

Signed-off-by: David Scott <dave.scott@unikernel.com>
@samoht
Copy link
Member

samoht commented Nov 19, 2015

I think a better fix would be to use ifprintf (see recent discussion with @yallop and @dbuenzli on efficient log functions)

On 19 Nov 2015, at 18:37, Dave Scott notifications@github.com wrote:

The Log.debug function will create a string to be logged via

Fmt.kstrf (fun s -> if !print_debug then print_endline s) fmt
before deciding whether to print them or not. In debug mode we print every
packet received and transmitted. This patch ensures that, when not in
debug mode, we don't generate vast quantities of strings which we never
print.

Signed-off-by: David Scott dave.scott@unikernel.com

You can view, comment on, or merge this pull request online at:

#26

Commit Summary

Avoid marshalling every packet to a string when not in debug mode
File Changes

M lib/s.mli (4)
M lib/server.ml (4)
Patch Links:

https://github.com/mirage/ocaml-9p/pull/26.patch
https://github.com/mirage/ocaml-9p/pull/26.diff

Reply to this email directly or view it on GitHub.

@talex5
Copy link
Contributor

talex5 commented Nov 19, 2015

Note that the logging PR (#18) solves this in a different way:

debug "S %s" (fun msg -> msg (Sexplib.Sexp.to_string (Response.sexp_of_t response)));

I thought this was the result of the previous discussions.

@djs55
Copy link
Member Author

djs55 commented Nov 19, 2015

OK, it sounds like a variant of #18 which still uses functors might be the best for now? I'll take a look later.

@djs55 djs55 closed this Nov 19, 2015
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.

None yet

3 participants