HDDS-15601. Improve ContainerHealthSchemaManager delete performance#10532
HDDS-15601. Improve ContainerHealthSchemaManager delete performance#10532umesh9794 wants to merge 1 commit into
Conversation
|
Thanks @umesh9794 for the patch. Please enable the |
While the speed improvement in |
|
@ArafatKhan2198 @devmadhuu |
|
@adoroszlai I have enabled the workflow in my fork. Thanks. Yes as I was not aware of the codebase very much, this method |
Yes, we can remove it as long as our test uses some other real code logic hitting the actual product code and able to test the batch delete performance. |
devmadhuu
left a comment
There was a problem hiding this comment.
Thanks @umesh9794 for the patch. Given few comments. Pls check.
| List<Long> inClauseBatch = new ArrayList<>(MAX_IN_CLAUSE_CHUNK_SIZE); | ||
|
|
||
| for (int i = 0; i < sortedIds.size(); ) { | ||
| int rangeStart = i; |
There was a problem hiding this comment.
This below code assumption seems incorrect that in real cluster that the unhealthy container ids all will be in continous sequence.
Real container IDs may not form one continuous sequence.
Consider this input:
1, 2, 4, 5, 7, 8, 10, 11
The PR sees four small continuous ranges and executes:
BETWEEN 1 AND 2
BETWEEN 4 AND 5
BETWEEN 7 AND 8
BETWEEN 10 AND 11
That means four separate DELETE statements.
The old implementation could delete all eight IDs using one statement:
WHERE container_id IN (1, 2, 4, 5, 7, 8, 10, 11)
With a larger realistic list containing many small pairs, the difference could become:
Old code: 50 DELETE statements
New code: 10,000 DELETE statements
Each statement must be compiled and executed by Derby. Consequently, production could become significantly slower even though this test becomes faster.
1, 2, 3, 4, ... 200,000
That is the best possible input for BETWEEN.
It does not test inputs such as:
1, 2, 10, 11, 20, 21, ...
There was a problem hiding this comment.
I think we can reduce delete statement count by combining BETWEEN and IN clauses in the same query using OR logic. Delay submitting the statement if number of items for IN reaches the limit or number of BETWEEN ranges reaches another (lower) threshold.
There was a problem hiding this comment.
@devmadhuu yes current code executes more delete statements and it might slowdown in the real production envs. Let me try to optimize this for production scenarios. Thanks!
There was a problem hiding this comment.
@adoroszlai sure, trying to check the logic to improve the performance. Thanks!
Thanks @devmadhuu for checking. Yes, product code uses another method: which is also covered by the performance test: So I suggest splitting the task:
|
Yes. I agree. |
What changes were proposed in this pull request?
Further speed up TestUnhealthyContainersDerbyPerformance by using
BETWEENpredicate instead of manyINclauses while deleting the contiguous container IDsWhat is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15601
How was this patch tested?
Ran the test locally and the elapsed time of this run is significantly reduced from ~313s to ~59s: