|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
[jira] Created: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer sizeMake LOBStoredProcedure on the server side smarter about the read buffer size
----------------------------------------------------------------------------- Key: DERBY-3769 URL: https://issues.apache.org/jira/browse/DERBY-3769 Project: Derby Issue Type: Improvement Components: Network Server Affects Versions: 10.4.1.3, 10.3.3.0, 10.5.0.0 Reporter: Kristian Waagan Assignee: Kristian Waagan Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. Assume the stream position is 64'000, and this is where we want to read from. The following happens: a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. e) The remaining 328 bytes are sent to the client. This issue deals with points b) and d), by avoiding the need to reset the stream. Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Commented: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612094#action_12612094 ] Kristian Waagan commented on DERBY-3769: ---------------------------------------- This issue can be fixed in the client, in the server or on both sides by adjusting the amount of requested data. There are advantages to doing it on both sides, for instance that new clients will behave better with older servers, but I think it is the server that knows best how much data can be sent so I plan to implement the fix there. Opinions? > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Updated: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan updated DERBY-3769: ----------------------------------- Attachment: derby-3769-1a-buffer_size_adjustment.diff 'derby-3769-1a-buffer_size_adjustment.diff' adjusts the buffer size according to the max size for VARCHAR/VARBINARY. Regression tests ran cleanly. Patch ready for review, also awaiting comments on the general approach. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Attachments: derby-3769-1a-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Updated: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan updated DERBY-3769: ----------------------------------- Derby Info: [Patch Available] > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Attachments: derby-3769-1a-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Commented: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612455#action_12612455 ] Knut Anders Hatlen commented on DERBY-3769: ------------------------------------------- I think it is correct to fix this on the server side only. If we want the fix on the client side, we need to give the client knowledge about maximum sizes for different server versions (not a big issue right now, since the max varchar/varbinary size hasn't changed) which sounds like unnecessary complexity if it only fixes performance issues with the combination of old server and new client. I think the fix looks good. I checked the code in CallableLocatorProcedures, and it seems to correctly request more data if the string is truncated, so the fix should be fine. You may consider the following cosmetic changes: 1) Instead of using Limits.DB2_VARCHAR_MAXWIDTH, we could have a dedicated constant (CLOBGETSUBSTRING_RETURN_LENGTH, or something) that we used both when we declared the stored procedures (in DataDictionaryImpl) and to truncate the return value in the procedures. This way it is easier to keep them consistent if we at some point change the definition of the procedures. 2) The javadoc comments have paragraphs marked as implementation notes which say that the length may be shorter than specified. I don't think these aren't actually implementation notes, but crucial points of the API that anyone programming against these procedures should be aware of. 3) The comments say that the length may be shorter because of client/server communication. I believe it is more correct to say that the length may be shorter than specified because the stored procedure returns a VARCHAR (or VARBINARY) and can therefore not return strings whose length exceed the max length for the data type. 4) Typo in javadoc for BLOBGETBYTES: smallar -> smaller > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Attachments: derby-3769-1a-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Updated: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan updated DERBY-3769: ----------------------------------- Attachment: derby-3769-1b-buffer_size_adjustment.diff Patch 1b addresses Knut Anders' comments. Knut Anders wrote: ----- I checked the code in CallableLocatorProcedures, and it seems to correctly request more data if the string is truncated, so the fix should be fine. ----- Yes, truncation is what happens currently, although at a different place in the code. Actions taken for the comments: 1) Introduced LOBStoredProcedure.MAX_RETURN_LENGTH and a comment. 2) You are correct. Removed implementation notes, commented the len argument. 3) Comments rewritten. 4) Typo fixed. Patch 1b ready for review. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Commented: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613582#action_12613582 ] Knut Anders Hatlen commented on DERBY-3769: ------------------------------------------- Patch 1b looks good to me. +1 to commit. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Updated: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan updated DERBY-3769: ----------------------------------- Derby Info: (was: [Patch Available]) Fix Version/s: 10.5.0.0 Thanks for looking at the patch Knut Anders. Committed 1b to trunk with revision 676912. Awaiting test run results before backporting. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Fix For: 10.5.0.0 > > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Resolved: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan resolved DERBY-3769. ------------------------------------ Resolution: Fixed Fix Version/s: 10.4.1.4 Backported to 10.4 with revision 677557. There are some JavaDoc conflicts for 10.3, but I think the fix can easily be ported if someone wishes to do so. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Fix For: 10.4.1.4, 10.5.0.0 > > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Closed: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan closed DERBY-3769. ---------------------------------- Closing issue. Note that points a) and e) in the list above haven't been resolved. It's not a bug, but a possible optimization (one could say it's a client side buffer adjustment) avoiding a round-trip to fetch a few bytes. Instead of adjusting the fetch buffer one could also consider prefetching. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Fix For: 10.4.1.4, 10.5.0.0 > > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
|
|
[jira] Reopened: (DERBY-3769) Make LOBStoredProcedure on the server side smarter about the read buffer size[ https://issues.apache.org/jira/browse/DERBY-3769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kristian Waagan reopened DERBY-3769: ------------------------------------ The fix isn't sufficient for Clob. Currently the buffer threshold is expressed in characters, but it seems it has to be expressed in bytes. Since we are transferring data over the line as UTF-8 (is this always the case?), a solution might be to always assume 3 bytes per character. The fix would then be to introduce a separate threshold for Clobs: MAX_CLOB_RETURN_LENGTH = MAX_RETURN_LENGTH / 3 The buffer size will be too small for most cases (i.e. when the Clob contains characters than can be represented by ASCII). In my opinion, that is an acceptable tradeoff compared to resetting the Clob stream and skipping data frequently on the server (see DERBY-3766). I'm sure a more sophisticated optimization can be implemented later. > Make LOBStoredProcedure on the server side smarter about the read buffer size > ----------------------------------------------------------------------------- > > Key: DERBY-3769 > URL: https://issues.apache.org/jira/browse/DERBY-3769 > Project: Derby > Issue Type: Improvement > Components: Network Server > Affects Versions: 10.3.3.0, 10.4.1.3, 10.5.0.0 > Reporter: Kristian Waagan > Assignee: Kristian Waagan > Fix For: 10.4.2.0, 10.5.0.0 > > Attachments: derby-3769-1a-buffer_size_adjustment.diff, derby-3769-1b-buffer_size_adjustment.diff > > > Derby has a max length for VARBINARY and VARCHAR, which is 32'672 bytes or characters (see Limits.DB2_VARCHAR_MAXWIDTH). > When working with LOBs represented by locators, using a read buffer larger than the max value causes the server to process far more data than necessary. > Say the read buffer is 33'000 bytes, and these bytes are requested by the client. This requests ends up in LOBStoredProcedure.BLOBGETBYTES. > Assume the stream position is 64'000, and this is where we want to read from. The following happens: > a) BLOBGETBYTES instructs EmbedBlob to read 33'000 bytes, advancing the stream position to 97'000. > b) Derby fetches/receives the 33'000 bytes, but can only send 32'672. The rest of the data (328 bytes) is discarded. > c) The client receives the 32'672 bytes, recalculates the position and length arguments and sends another request. > d) BLOBGETBYTES(locator, 96672, 328) is executed. EmbedBlob detects that the stream position has advanced too far, so it resets the stream to position zero and skips/reads until position 96'672 has been reached. > e) The remaining 328 bytes are sent to the client. > This issue deals with points b) and d), by avoiding the need to reset the stream. > Points a) and e) are also problematic if a large number of bytes are going to be read, say hundreds of megabytes, but that's another issue. > It is unfortunate that using 32 K (32 * 1024) as the buffer size is almost the worst case; 32'768 - 32'672 = 96 bytes. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
| Free Forum Powered by Nabble | Forum Help |