Running H2 on a Raspberry PI I noticed a  CPU usage of 5% even when nothing 
was going on in the database. I found that a "MVStore background writer" 
was active every 50 milliseconds. Debugging the cause I came across this 
line

     int sleep = Math.max(1, millis / 10);

in MVStore's setAutoCommitDelay method, which at least could nearly explain 
the high frequency wake-ups given a default commit delay of 1000 I thought 
to have read about, except for a factor of two.

I noticed that MVStore.setAutoCommitDelay is called by my first query 
through JdbcConnectionPool.getConnection(), and from MVStore.<init> where 
the connection string is

jdbc:h2:file:/home/harald/data/ekl/ekldb;TRACE_LEVEL_SYSTEM_OUT=1

with a hard coded value of millis=1000. Shortly later it is called again 
through Database.setWriteDelay with millis taken from Database.writeDelay 
hardcoded to Constants.DEFAULT_WRITE_DELAY, which is 500.

This finally explained the 50 milliseconds wakeups. But two questions arise:

1) Why is the background writer set twice?

2) Why the division by 10 of the millis? How about targeting the delta by 
90% with a first delay and then delay for the missing delta? (I assume you 
tried an old fashioned java.util.Timer and it was not up to the task?)

I'll try setting the WRITE_DELAY to a higher value to not drain unnecessary 
CPU power on the PI, since risking a data loss on this PI database is no 
big deal.

Harald.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to