[PATCH] Avoid unnecessary string handling for UPDATE commands.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] Avoid unnecessary string handling for UPDATE commands.

by kevin brintnall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 - only copy as many bytes as necessary
 - during journal replay, avoid unnecessary copy (string is discarded)

Thank you Thorsten von Eicken <tve@...>
---
 src/rrd_daemon.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index 0ca1818..1946003 100644
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
@@ -1312,7 +1312,8 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */
   cache_item_t *ci;
 
   /* save it for the journal later */
-  strncpy(orig_buf, buffer, sizeof(orig_buf)-1);
+  if (sock != NULL)
+    strncpy(orig_buf, buffer, buffer_size);
 
   status = buffer_get_field (&buffer, &buffer_size, &file);
   if (status != 0)
--
1.6.4

_______________________________________________
rrd-developers mailing list
rrd-developers@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

Parent Message unknown Re: [PATCH] Avoid unnecessary string handling for UPDATE commands.

by Tobias Oetiker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kevin,

Today kevin brintnall wrote:

>  - only copy as many bytes as necessary
>  - during journal replay, avoid unnecessary copy (string is discarded)
>
> Thank you Thorsten von Eicken <tve@...>

you di have perfect timing :-) so it will be an 1.4.1 announement today. But I
guess the performance impact is well worth it. Thank you!

cheers
tobi


> ---
>  src/rrd_daemon.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
> index 0ca1818..1946003 100644
> --- a/src/rrd_daemon.c
> +++ b/src/rrd_daemon.c
> @@ -1312,7 +1312,8 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */
>    cache_item_t *ci;
>
>    /* save it for the journal later */
> -  strncpy(orig_buf, buffer, sizeof(orig_buf)-1);
> +  if (sock != NULL)
> +    strncpy(orig_buf, buffer, buffer_size);
>
>    status = buffer_get_field (&buffer, &buffer_size, &file);
>    if (status != 0)
>

--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi@... ++41 62 775 9902 / sb: -9900

_______________________________________________
rrd-developers mailing list
rrd-developers@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers