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

not compact automatically when getChunksFillRate() is below autoCompactFillRate #2600

Open
auntyellow opened this issue May 4, 2020 · 5 comments

Comments

@auntyellow
Copy link
Contributor

In h2-1.4.200 when I set autoCompactFillRate (e.g. 80%), MVStore file will compact once getChunksFillRate() is below the value. But in the latest master branch it does not seem to compact any longer.

I'm testing an insert-delete scenario and monitoring getChunksFillRate(), using the stable version (h2-1.4.200) and the latest snapshot (h2-1.4.201-SNAPSHOT), both set autoCompactFillRate to 80. In the stable version, chunks fill rate slowly decreases to 79 and then rapidly increases to 81-94, again and again; In the snapshot version, chunks fill rate slowly decreases below 80 (now reach to 70 and keep unchanged several hours).

@andreitokar
Copy link
Contributor

andreitokar commented May 4, 2020

First of all, autoCompactFillRate is a suggestion, not a guarantee. You are making some assumptions here about internal (undocumented) behaviour. For instance getChunksFillRate() may be not what you think it is, there is also getFillRate(). In general, I fail to understand what is the point you are making here.
I would monitor and compare some externally observable metrics like CPU consumption and file size instead.

@auntyellow
Copy link
Contributor Author

Thank you for the advice. During my test on insert-delete scenario, however, the file generated by h2-1.4.201-SNAPSHOT (660M) is much bigger than h2-1.4.200 (490M), for the same sample data; and query is much slower (~17s vs ~11s). Let me prepare a reproducible test case...

@auntyellow
Copy link
Contributor Author

h2-1.4.201-SNAPSHOT redefined autoCompactFillRate in MVStore:

  • For a positive percentage, compact by moving chunks when getFillRate() is below autoCompactFillRate (call MVStore.compact(targetFillRate, write));
  • For a negative percentage, compact by rewrite chunks when getChunksRate() is below -autoCompactFillRate (call MVStore.compactMoveChunks(targetFillRate, moveSize)).

When I changed autoCompactFillRate from 80 to -80 in 1.4.201-SNAPSHOT, the behavior (disk space usage and performance) is simillar to 1.4.200.

Should re-document MVStore.Builder.autoCompactFillRate() and database setting AUTO_COMPACT_FILL_RATE in h2-1.4.201.

@auntyellow auntyellow reopened this May 17, 2020
auntyellow added a commit to xqbase/metric that referenced this issue May 17, 2020
auntyellow added a commit to xqbase/metric that referenced this issue May 17, 2020
@andreitokar
Copy link
Contributor

No it should not be documented, and it will definitely be removed at some point. The only reason it is still there is to have some temporary workaround, if new version does not perform well. Difference in file size between 490 and 660 MB is not something I would worry about.
On the other hand, if some of your query become much slower, that might be an unrelated issue, and test case is due.

@auntyellow
Copy link
Contributor Author

H2 now has two types of compaction:

  • rewrite chunks, to increase MVStore.getChunksFillRate();
  • move chunks, to increase MVStore.getFillRate().

H2 1.4.200 rewrite chunks in background and move chunks in database shutdown, while current 1.4.201-SNAPSHOT rewrite chunks for negative autoCompactFillRate and move chunks for positive one.

May introduce two different settings for these two types of compaction.

auntyellow added a commit to xqbase/metric that referenced this issue May 27, 2020
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

No branches or pull requests

2 participants